Note that there are some explanatory texts on larger screens.

plurals
  1. POTextView displaying text in One line when adding rows programatically in Table Layout
    text
    copied!<p>I have a table layout after some view in my xml file. Below is the code.</p> <pre><code>&lt;ScrollView&gt; &lt;LinearLayout&gt; .................................. ..................................... &lt;Button android:id="@+id/fetchbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="show details" android:layout_margin="6dip" android:layout_gravity="center_horizontal" android:onClick="buttonOnClick"/&gt; &lt;TableLayout android:id="@+id/mytable_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:orientation="vertical" &gt; &lt;/TableLayout&gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; </code></pre> <p><strong>Below is the code to add the rows programatically for a table layout:</strong></p> <pre><code>public void buttonOnClick(View view) { showData(); } public void showData() { List&lt;DataSource&gt; data = dbHelper.getData(selectedoption); TableLayout tl = (TableLayout)findViewById(R.id.mytable_layout); for(DataClass dataclass:data) { TableRow tr = new TableRow(ViewScreen.this); TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT); tr.setLayoutParams(params); TextView labelTV = new TextView(ViewScreen.this); labelTV.setText(dataclass.getColumnName()); labelTV.setTextColor(Color.RED); TableRow.LayoutParams paramsTV1 = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT); labelTV.setLayoutParams(paramsTV1); tr.addView(labelTV); // Creating a TextView to house the value of the after-tax income TextView valueTV = new TextView(ViewScreen.this); valueTV.setText(dataclass.getColumnValue()); valueTV.setTextColor(Color.BLACK); TableRow.LayoutParams paramsTV2 = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT); valueTV.setLayoutParams(paramsTV2); tr.addView(valueTV); // Adding the TableRow to the TableLayout tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); } } </code></pre> <p>So as per the above code, it's working fine. But the table row is always with one line. The <code>table row height</code> is not <code>increased</code> according to the content. Instead the part of text goes off screen and invisible. Can some one please help to solve this issue?</p> <p><strong>Picture:</strong></p> <p><img src="https://i.stack.imgur.com/7qHB1.png" alt="enter image description here"></p>
 

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