-1
我正在开发一个android应用程序,我需要在发生事件时刷新表格。那是当用户点击一个按钮时,表格现在应该改变显示新的数据。所以我为此使用了removeAllViews。然后,我会动态地将这些行添加到表中。发生的情况是,当行数小于以前的行数时,将显示新行并在其下面显示旧行。你能告诉我需要做什么吗?表格布局不正常刷新 - Android
TableLayout tableLayout1;
public void displayPanel1(int co) // dynamically add table
{
LinearLayout ll = (LinearLayout)findViewById(R.id.asdf);
LayoutParams lp = new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
for(int i=0;i<co;i++) {
TableRow tR = new TableRow(this);
for(int j=0;j<12;j++) {
TextView tv2=new TextView(this);
tv2.setText(i+j+""+"\n"+"h");
tR.addView(tv2);
}
tableLayout1.addView(tR);
}
ll.addView(tableLayout1, lp);
}
在点击事件中,我写了tableLayout1.removeAllViews();并再次调用displayPanel()函数
你能告诉我们一些相关的代码吗?没有看到你在做什么,我们只能猜测问题可能是什么。 –
你使用任何主题?尝试使布局无效。 – Zeus
我没有使用任何主题。我也尝试失效..但它仍然不工作:( – user2736177