【问题标题】:TableRow layout inflator not showing data in landscape modeTableRow 布局充气器未在横向模式下显示数据
【发布时间】:2011-11-23 12:25:47
【问题描述】:

我遇到了一个奇怪的问题。我正在通过像这样膨胀表格行来创建表格

TableLayout table = (TableLayout) findViewById(R.id.tablelay);
LayoutInflater inflater = getLayoutInflater();

for (int j = 0; j < limit ; j++) {

    TableRow row = (TableRow) inflater.inflate(R.layout.row_details, table, false);

     t1 = (TextView) row.findViewById(R.id.firstTxt);
     t1.setText(""+ firstData[j]);

     t2 = (TextView) row.findViewById(R.id.secondTxt);
     t2.setText(""+ secondData[j]);
     table.addView(row, new TableRow.LayoutParams(
                    TableRow.LayoutParams.FILL_PARENT,
                    TableRow.LayoutParams.WRAP_CONTENT)); 
 }

“row_details.xml”是一个包含两个文本视图(“firstTxt”、“secondTxt”)的布局。 我能够添加数据并显示在屏幕上。

当我将它旋转到横向模式时,问题就出现了,然后所有数据都丢失了。最初我认为这可能是由于方向问题(即由于重新加载活动而导致数据丢失)。

但是当我第一次在横向模式下加载活动时,没有数据显示,现在旋转到纵向模式显示数据。所以我认为这是由于在横向模式下充气造成的。

观察:- 纵向视图显示数据,横向视图不显示数据

我该如何解决这个问题?....提前谢谢。

【问题讨论】:

    标签: android android-inflate


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      添加清单活动标签configChange="orientation"

      【讨论】:

      • noo....当我以横向模式加载活动时,不会显示数据。这里我没有改变方向
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-27
      • 2017-10-05
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多