2011-12-03 38 views
1

我一直試圖爲一組對話框中的每個項目動態添加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" /> 

+0

嘗試高(> = 10px的)和可見性設置爲true,看看是否有幫助 – ComputerSaysNo

+0

我想你應該嘗試像 NEWROW = dialogue.newrow() –

+0

父類被隱藏的容器一些事情。修改它使其可見。 – fauxriginal

回答

0

嘗試使用

tr.setLayoutParams(新TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,TableRow.LayoutParams.FILL_PARENT));

改爲!!

+0

fauxriginal您是否已經使用@ smanandhar的解決方案獲得任何成功?我也有同樣的問題。 – 2012-09-04 01:02:13

+0

沒有爲我工作 –