Monday, February 21, 2011

Creating dynamic controls.

Here is the code for dynamically creating controls in the table layout...
TableLayout tl=(TableLayout)findViewById(R.id.NewsTable);
 for (int i = 0; i < 16; i++)
 {
TableRow tr=new TableRow(this);
TextView TV=new TextView(this);
 TV.setText("Dynamic Button--"+i);
ImageView IV=new ImageView(this);
 Uri imgUri=Uri.parse("android.resource://com.example.hello/"+R.drawable.icon);
IV.setImageURI(imgUri);
 tr.addView(IV);
 tr.addView(TV);
tl.addView(tr);


No comments:

Post a Comment