I want to dynamically add rows to a table. This is my code.
TableRow tableRow = null;
TextView textView = null;
ImageView imageView = null;
TableLayout tableLayout = (TableLayout)findViewById(R.id.tableLayout);
RelativeLayout relativeLayout = null;
for (String string: listOfStrings) {
tableRow = new TableRow(this);
relativeLayout = (RelativeLayout) View.inflate(this,
R.layout.row, null);
textView = (TextView) relativeLayout.getChildAt(0);
textView.setText(string);
imageView= (ImageView) relativeLayout.getChildAt(1);
imageView.setBackgroundColor(R.color.blue);
tableRow.addView(relativeLayout);
tableLayout.addView(tableRow);
}
I created a line layout with a width of fill_parent, with text on the left to the left and with an image on the right to the right. However, when I run this program, the line width appears wrap_content instead of fill_parent with text overlapping the image. Please help. Thanks
source
share