Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically added table rows not appearing
    text
    copied!<p>I have seen many posts regarding dynamically adding table rows, but I am not sure what I'm missing.</p> <p>When I execute the following, nothing is displayed (aside from application title bar).</p> <p>My Layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout android:id="@+id/table_view_test_main" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;ScrollView android:id="@+id/tvt_scroll" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" &gt; &lt;RelativeLayout android:id="@+id/tvt_scroll_relative" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;TableLayout android:id="@+id/tvt_tableview" android:layout_width="fill_parent" android:layout_height="wrap_content" &gt; &lt;/TableLayout&gt; &lt;/RelativeLayout&gt; &lt;/ScrollView&gt; &lt;/RelativeLayout&gt; </code></pre> <p>My Activity:</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.table_view); TableLayout tableLayout = (TableLayout) findViewById(R.id.tvt_tableview); TableRow tableRow = new TableRow(this); tableRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); TextView column1 = new TextView(this); column1.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); column1.setBackgroundColor(Color.YELLOW); column1.setTextColor(Color.BLUE); column1.setText("Col1 Value"); tableRow.addView(column1); TextView column2 = new TextView(this); column2.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); column2.setBackgroundColor(Color.RED); column2.setTextColor(Color.GREEN); column2.setText("Col2 Value"); tableRow.addView(column2); tableLayout.addView(tableRow, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)); //tl.refreshDrawableState(); //findViewById(R.id.tvt_scroll_relative).refreshDrawableState(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload