这里的代码:
DtoCbpOutcome[] outcomes = cbp.Outcomes;
Log.d(_logTag, "# of outcomes: " + Integer.toString(outcomes.length));
TableLayout tl = (TableLayout) findViewById(R.id.tbl_cbp_outcomes);
for (int i = 0; i < outcomes.length; i++) {
// Text Views:
// public String Description;
TableRow tr = new TableRow(appCtx);
tr.setLayoutParams(tbl_lay_parms);
// Row Count
TextView row_num = new TextView(appCtx);
temp_string = Integer.toString(i + 1);
row_num.setText(temp_string);
row_num.setLayoutParams(lay_parms);
tr.addView(row_num);
// Description
TextView desc = new TextView(appCtx);
temp_string = outcomes[i].Description;
desc.setText(temp_string);
desc.setLayoutParams(lay_parms);
tr.addView(desc);
tl.addView(tr, tbl_lay_parms);
}
从布局文件:
<TableLayout
android:id="@+id/tbl_cbp_outcomes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp" >
</TableLayout>
我认为这是我正在构建的结构:
TableLayout (R.id.tbl_cbp_outcomes)
TableRow (tr)
TextView (row_num)
TextView (desc)
但该行未显示在布局视图 (activity_business_plan.xml) 中。
我在这里做错了什么?
谢谢
更新 1
从日志中:结果数:5,由outcomes.length
更新 2
完整的布局xml:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/green_nature_header"
android:padding="3dp"
android:text="@string/label_project_relationships"
android:textColor="@color/White"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_cbp_rel_global_priorities"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:text="@string/double_dash" />
<TextView
android:id="@+id/tv_cbp_related_regional_priority_strategies"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:text="@string/double_dash" />
<TextView
android:id="@+id/tv_cbp_related_whole_system_priorities"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:text="@string/double_dash" />
<TextView
android:id="@+id/tv_cbp_related_demonstration_priorities"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:text="@string/double_dash" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/green_nature_header"
android:padding="3dp"
android:text="@string/label_vision_statement"
android:textColor="@color/White"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_cbp_vision_statement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:text="@string/double_dash" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/green_nature_header"
android:padding="3dp"
android:text="@string/label_outcomes"
android:textColor="@color/White"
android:textStyle="bold" />
<TableLayout
android:id="@+id/tbl_cbp_outcomes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp" >
</TableLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/green_nature_header"
android:padding="3dp"
android:text="@string/label_strategies"
android:textColor="@color/White"
android:textStyle="bold" />
<TableLayout
android:id="@+id/tbl_cbp_strategies"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp" >
</TableLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/green_nature_header"
android:padding="3dp"
android:text="@string/label_intermediate_results"
android:textColor="@color/White"
android:textStyle="bold" />
<TableLayout
android:id="@+id/tbl_cbp_intermediate_results"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp" >
</TableLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/green_nature_header"
android:padding="3dp"
android:text="@string/label_activities"
android:textColor="@color/White"
android:textStyle="bold" />
<TableLayout
android:id="@+id/tbl_cbp_activities"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp" >
</TableLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/green_nature_header"
android:padding="3dp"
android:text="@string/label_risks"
android:textColor="@color/White"
android:textStyle="bold" />
<TableLayout
android:id="@+id/tbl_cbp_risks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp" >
</TableLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/green_nature_header"
android:padding="3dp"
android:text="@string/label_keywords"
android:textColor="@color/White"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_cbp_keywords"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:text="@string/double_dash" />
<TextView
android:id="@+id/tv_cbp_modified"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="3dp"
android:text="@string/double_dash"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</ScrollView>