我一直試圖爲一組對話框中的每個項目動態添加TableRows,但行沒有顯示出來。在逐步調試時,我可以看到TableLayout上的子項數量增加,但之後沒有顯示。動態添加的TableRows在TableLayout中不可見
添加行TableLayout對話含有TableLayout
List<Dialogue> content = post.getDialogue();
for (int i = 0; i < content.size(); i++) {
Dialogue d = content.get(i);
TableRow tr = (TableRow) layoutInflater.inflate(R.layout.chat_post_dialogue_include, dialogue, false);
tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
TextView label = (TextView) tr.findViewById(R.id.label);
label.setText(d.getLabel());
TextView dialogueLine = (TextView) tr.findViewById(R.id.dialogue_line);
dialogueLine.setText(d.getPhrase());
dialogue.addView(tr);
}
佈局
<TextView
android:id="@+id/title"
style="@style/title" />
<TableLayout
android:id="@+id/dialogue"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/title" />
的TableRow佈局
<TextView
android:id="@+id/label"
android:gravity="top" />
<TextView
android:id="@+id/dialogue_line" />
嘗試高(> = 10px的)和可見性設置爲true,看看是否有幫助 – ComputerSaysNo
我想你應該嘗試像 NEWROW = dialogue.newrow() –
父類被隱藏的容器一些事情。修改它使其可見。 – fauxriginal