Iam trying to create a table with borders using TableLayout. If I add static rows in xml file i am able to see the borders. But the problem arises if I try to add some dynamic rows. Data for the table comes dynamically. Can anyone help in solving this problem. If possible please provide the source code(.ja开发者_开发百科va file and .xml file).
You can create a rectangle image to use as a background for the row. TableRow
extends View
, so this should work (untested).
TableRow row = new TableRow (this);
row.setBackgroundResource (android.R.drawable.edit_text);
// rest of your code
If it doesn't work, the (tested) solution is to add a color background to the table and padding to the row.
精彩评论