I\'m creating a Tablelayout with many TableRows dynamically, for example:
for(int i = 0; i
I found something cool and its working fine...
TableLayout tl=(TableLayout)findViewById(R.id.maintable);
....
TableRow tr1 = new TableRow(this);
tr1.setLayoutParams(newLayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
TextView textview1 = new TextView(this);
textview1.setText(etFirstname.getText());
textview1.setPadding(5, 0, 0, 0);
textview1.setTextColor(Color.YELLOW);
textview1.setBackgroundColor(Color.GREEN);
tr1.addView(textview1);
TextView textview2 = new TextView(this);
textview2.setText(etAge.getText());
//textview2.setText(etAge.getText());
textview2.setPadding(5, 0, 0, 0);
textview2.setTextColor(Color.RED);
textview2.setBackgroundColor(Color.GRAY);
tr1.addView(textview2);
tr1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
TableRow tr1=(TableRow)v;
TextView tv1= (TextView)tr1.getChildAt(0);
Toast.makeText(getApplicationContext(),tv1.getText().toString(),Toast.LENGTH_SHORT).show();
}
});
tl.addView(tr1);