0
我已經在xml中創建了表格佈局。在運行時,我使用的是第一種情況,我正在填充表格佈局。但是,在第二種情況下,我再次將內容添加到相同的佈局。它們會在佈局結束時累積起來。不過,我需要清除之前的佈局內容。 我可以用這些removeallview()方法,它不工作..我的代碼如何清除表格佈局的前一個內容?
ll=(LinearLayout)findViewById(R.id.linear1);
for (int i = 0; i <= 1; i++) {
table=new TableLayout(mContext);
TableLayout.LayoutParams tableParams= new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT);
int leftMargin=0;
int topMargin=0;
int rightMargin=0;
int bottomMargin=0;
tableParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
table.setLayoutParams(tableParams);
lf_header = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
header_view = lf_header.inflate(R.layout.header, null);
DBAdapter dbAdapter=DBAdapter.getDBAdapterInstance(this);
try {
dbAdapter.createDataBase();
} catch (IOException e) {
Log.i("*** select ",e.getMessage());
}
dbAdapter.openDataBase();
if(i==0){
((TextView) header_view.findViewById(R.id.header_txt1)).setText("Over Due");
header_view.setBackgroundColor(Color.RED);
table.addView(header_view);
ll.addView(table);
任何建議?
示例代碼是欣賞..提前
謝謝..
當點擊 「全部」 按鈕,這個表格佈局created.after我點擊另一個按鈕和我再次點擊「ALL」按鈕。建議在哪裏刪除或使用table.removeAllViewsInLayout()? – Selva
當你需要刪除只是叫它 – Rasel
這是不明確表 – Selva