Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid TableLayout not Displaying
    primarykey
    data
    text
    <p>I've got a class whose content is set to a layout which has a few buttons and a TableLayout.</p> <p>The real work that makes the TableLayout is in a separate static helper class, which has a method that returns the desired table.</p> <p>However, the table is not displaying. What humiliatingly simple fact am I missing?</p> <p>Here is the class whose content is set to the layout:</p> <pre><code>public class TesterActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TableLayout table = (TableLayout) findViewById(R.id.table); table = TableHelper.getTable_BINARY_NUMBERS(getApplicationContext(), 5, 25); } } </code></pre> <p>And here is the helper class that creates the Table's meat:</p> <pre><code>public class TableHelper { public static TableLayout getTable_BINARY_NUMBERS(Context context, int numRows, int numCols) { TableLayout table = new TableLayout(context); table.setStretchAllColumns(true); table.setShrinkAllColumns(true); TableRow[] rows = new TableRow[numRows]; for (int row=0; row&lt;numRows; row++) { rows[row] = new TableRow(context); for (int col=0; col&lt;numCols-1; col++) { TextView num = new TextView(context); num.setText("0"); rows[row].addView(num); } TextView rowText = new TextView(context); rowText.setText("Row " + (row + 1)); rowText.setTextAppearance(context, android.R.style.TextAppearance_Small); rows[row].addView(rowText); rows[row].setPadding(0, 50, 0, 0); table.addView(rows[row]); } return table; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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