Динамически добавленные TableRows не видны в TableLayout - PullRequest
1 голос
/ 04 декабря 2011

Я пытался динамически добавлять TableRows для каждого элемента в наборе диалогов, но строки не отображаются. Проходя через отладчик, я вижу, как увеличивается число дочерних элементов в 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);
}

Макет, содержащий TableLayout

<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" />

1 Ответ

0 голосов
/ 03 января 2012

Попробуйте использовать

tr.setLayoutParams (новые TableRow.LayoutParams (TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.FILL_PARENT));

вместо !!

...