Jerome Campeaux Jerome Campeaux - 22 days ago 9
Android Question

Java Android table not displayed

I made the following code :

TableLayout tableLayout = (TableLayout) tmpView.findViewById(R.id.tableLayout);
TableRow tableRow;
TableLayout.LayoutParams lp = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
for (int i = 0; i < modules.length(); i++) {
tableRow = new TableRow(this.getActivity());
tableRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
TextView title = null;
TextView grade = null;
try {
title = new TextView(this.getActivity());
title.setText(modules.getJSONObject(i).getString("title"));
grade = new TextView(this.getActivity());
grade.setText(modules.getJSONObject(i).getString("grade"));
} catch (JSONException e) {
e.printStackTrace();
}
tableRow.addView(title);
tableRow.addView(grade);
tableLayout.addView(tableRow, lp);
}


But nothing displayed on the screen.

Do you know why it's not working ?

Answer

Solution found, TableLayout declared dynamically then set on the view

Comments