I\'m creating a Tablelayout with many TableRows dynamically, for example:
for(int i = 0; i
change your code as for making TableRow Clickable set tr.setClickable(true) and add a setOnClickListener:
private void createView(TableRow tr, TextView t, String viewdata) {
t.SetText(viewdata, TextView.BufferType.Editable);
//adjust the porperties of the textView
//t.SetLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
//You have to use Android.Graphics.Color not System.ConsoleColor;
t.SetTextColor(Color.Blue);
t.SetBackgroundColor(Color.Cyan);
t.SetPadding(5, 0, 0, 0);
tr.SetPadding(0, 1, 0, 1);
tr.SetBackgroundColor(Color.Black);
tr.setClickable(true);
tr.setOnClickListener(tablerowOnClickListener);//add OnClickListener Here
tr.AddView(t); // add TextView to row.
}
private OnClickListener tablerowOnClickListener = new OnClickListener() {
public void onClick(View v) {
//GET TEXT HERE
String currenttext = ((TextView)v).getText().toString());
}
};