i am working with TableLayout,i want to create up to 50 rows dynamically my row having one image view and text view,i am creating 50 dynamic rows in OnStart() method by using for loop Here is My code..., is it best practice to do like this ? can any one tell me which is the best way to do this or can you refer me an links
public void onStart() {
{
//Items is Array list of 50 objects
TableLayout myTable= (TableLayout)findViewById(R.id.myTableLayout);
for (int i=0;i<Items.size();i++)
{
TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
TextView rowText= new TextView(this);
rowText.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
rowText.setText("dyanamic text");
ImageView rowImg = new ImageView(this);
rowImg.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
Bundle extras = getIntent().getExtras();
Drawable dra = Drawable.createFromPath(extras.getString("IconImagePath"));
rowImg.setImageDrawable(dra);
tableRow.addView(rowImg);
tableRow.addView(rowText);
myTable.addView(tableRow);
}
}