So I am creating a table that contains the texts that are very long with 4-5 columns, and what I need is the table that is able to WRAP content in each column (in width and height). I want all of my content can be seen. If the texts are long, the table can automatically makes the content to next line. (Right now, it still fills the whole emulator width, so other columns can't be seen)
Here is my current code at MainActivity.java:
int rows = c.getCount();
int cols = c.getColumnCount();
c.moveToFirst();
// outer for loop
for (int i = 0; i < rows; i++)
{
TableRow row = new TableRow(this);
row.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
// inner for loop
for (int j = 0; j < cols; j++)
{
TextView tv = new TextView(this);
tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
tv.setGravity(Gravity.LEFT);
tv.setTextSize(10);
tv.setPadding(0, 5, 0, 5);
tv.setText(c.getString(j));
row.addView(tv);
}
c.moveToNext();
mytable.addView(row);
}
what I want if the text is long is like this:
id description name
1000 the quick brown John
fox jumps over Doe
the dog
But my current one is like this
id description name
1000 the quick brown fox jumps over the dog
name field can't be seen since the column 2's text is very long. Please help me with this matter. Thank you..