• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

TableLayout Onclick

ramesh_bh

Newbie
Sep 16, 2010
17
1
Hi,

I have a table and rows in my application,i want to add onclick for each row.
i have done some thing like this :
TableLayout table = new TableLayout(this);
for (int i = 0; i < list.size(); i++) {
TextView t = new TextView(this);
TextView t1 = new TextView(this);
TextView t2 = new TextView(this);

HashMap map = (HashMap) list.get(i);
Set set = map.keySet();
int j = 0;
for (Iterator iterator = set.iterator(); iterator.hasNext();) {
String object = (String) iterator.next();
String value = (String) map.get(object);
tr = new TableRow(this);
switch (j) {
case 0:
t.setText(value);
break;
case 1:
t1.setText(value);
break;
case 2:
t2.setText(value);
break;

j++;
}
tr.addView(t, new TableRow.LayoutParams(1));
tr.addView(t1, new TableRow.LayoutParams(2));
tr.addView(t2, new TableRow.LayoutParams(3));

table.addView(tr,new TableLayout.LayoutParams());

But i got all the results when i click any row. i want to capture particular row and its corresponding values when i click.

Please help

Ramesh
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones