I would like to add an additional independent row in my existing activity that already consist of a table layout within a tab. The new table should be below the existing table layout. However, the independent table is not showing. What is the best way to do that?
XML:
<LinearLayout
android:id="@+id/tab3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingTop="60dp" >
<ScrollView
android:id="@+id/scrollView_CustomerProductList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical|start">
<TableLayout
android:id="@+id/Tab3_Table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<TableRow
android:id="@+id/table_Row1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
<ListView
android:id="@+id/list_image"
android:layout_width="15dip"
android:layout_height="30dip"
android:src = "@drawable/banana_chair"/>
<ListView
android:id="@+id/list_image2"
android:layout_width="80dip"
android:layout_height="80dip"
android:src="@drawable/circular_chair"/>
<ListView
android:id="@+id/list_image3"
android:layout_width="80dip"
android:layout_height="80dip"
android:src="@drawable/purplechair"/>
</TableRow>
<TableRow
android:id="@+id/table_Row2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
</TableRow>
<TableRow
android:id="@+id/table_Row3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
</TableRow>
</TableLayout>
</ScrollView>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TableLayout
android:id="@+id/Cost_table"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<TableRow
android:id="@+id/costTable_Row1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TableRow>
<TableRow
android:id="@+id/costTable_Row1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
code that is calling the independent row:
TableLayout cost_table = (TableLayout) findViewById(R.id.Cost_table);
// Create Table Header
TableRow tl_cost = new TableRow(this);
tl_cost.setId(10);
tl_cost.setBackgroundColor(Color.BLACK);
tl_cost.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
// Create Table Columns
TextView cost_tab3 = new TextView(this);
cost_tab3.setId(50);
cost_tab3.setText("Total Cost 总价:");
cost_tab3.setTextColor(Color.WHITE);
cost_tab3.setPadding(50, 20, 50, 20);
tl_cost.addView(cost_tab3);// add the column to the table row here
TextView cost_totalamt = new TextView(this);
cost_totalamt.setId(50);
cost_totalamt.setText("total sum:");
cost_totalamt.setTextColor(Color.WHITE);
cost_totalamt.setPadding(300, 20, 300, 20);
tl_cost.addView(cost_totalamt);// add the column to the table row here
cost_table.addView(tl_cost, new TableLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));