0
在我的XML佈局,我有的TableRow編程方式添加不顯示
<TableLayout
android:id="@+id/gridview"
android:layout_height="fill_parent"
android:layout_width="fill_parent" >
</TableLayout>
和活動
setContentView(R.layout.main);
/* Find Tablelayout defined in main.xml */
TableLayout tl = (TableLayout)findViewById(R.id.gridview);
/* Create a new row to be added. */
TableRow tr = new TableRow(this);
tr.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
/* Create a Button to be the row-content. */
Button b = new Button(this);
b.setText("Dynamic Button");
b.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
/* Add Button to row. */
tr.addView(b);
/* Add row to TableLayout. */
tl.addView(tr,new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
但在tablelayout按鈕和TextView中不會顯示。任何想法爲什麼?
你嘗試使用invalidate()嗎? – 2011-12-30 19:39:34
@biovamp我不知道它會如何幫助。你能詳細說明嗎? – 2011-12-30 20:28:59