- I have a TableLayout and I need to add TableRows at runtime.
- I need to add an ImageView and a TextView to each TableRow and add the row to TableLayout.
- And the TextView added to each row should be displayed in multiple lines if the length of the text is much long.
- I tried setSingleLine(false), setMaxWidth(100), setMaxLines(3), nothing is working but If I add the TableRow in xml with android:singleLine=”false” it shows the text in multiple lines.
Please suggest me…….
SOLVED THROUGH THIS CODE
TableRow.LayoutParams tlparams = new TableRow.LayoutParams(
TableRow.LayoutParams.WRAP_CONTENT,
TableRow.LayoutParams.WRAP_CONTENT);
TextView textView = new TextView(this);
textView.setLayoutParams(tlparams);
textView.setText("New text: " + s);
textView.setSingleLine(false);
The below code will work for you.