我正在动态创建一个包含许多 TableRows 的 Tablelayout,例如:
for(int i = 0; i<cont; i++)
{
id[i] = customers[i].CustomerNumber;
//Create a new row to be added.
tr = new TableRow(this);
//Create text views to be added to the row.
tv = new TextView(this);
//Put the data into the text view by passing it to a user defined function createView()
createView(tr, tv, id[i].ToString());
//Add the new row to our tableLayout tl
tl.AddView(tr);
}
这是 createView 代码:
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.AddView(t); // add TextView to row.
}
我的问题是我想从包含单行中所有内容的 TableLayout 中进行选择,以便能够选择并响应单击事件,以便将其用于进一步的目的。