Results 1 to 1 of 1
Thread: TableRow OnClick Listener
- 05-26-2011, 02:48 AM #1
TableRow OnClick Listener
I am doing some Android programming, and I had a question about onClickListeners (android is done in Java).
I am dynamically creating table rows as I walk down Cursor results of an SQL query and adding them to the table. Right before I add the table to the row, I am trying to set a listener for EACH row, and the action will be based on the row. The problem is that when the action is triggered, 'rowCount' keeps evaluating to the total # of Rows, instead of what it was at the time I created the Listener. Any way to get this to work?
rowCount=-1;
while(values.moveToNext()){
RowCount++;
System.out.println("On Row "+RowCount);
trA[RowCount] = new TableRow(this);
trA[RowCount].setId(RowCount);
trA[RowCount].setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
// SetValues(trA[RowCount].getId());
}
});
//Add the Row to the table
tl.addView(trA[RowCount]);
}
Similar Threads
-
OnClick inside a loop
By sehudson in forum New To JavaReplies: 9Last Post: 05-29-2011, 06:14 AM -
help with onclick
By unplugged in forum Java AppletsReplies: 4Last Post: 12-15-2009, 12:24 AM -
Globally disable onclick
By karnesb in forum New To JavaReplies: 4Last Post: 10-13-2008, 03:45 AM -
use of onclick function
By m4tt in forum New To JavaReplies: 1Last Post: 02-16-2008, 03:03 AM -
JButton onClick?
By Joe2003 in forum AWT / SwingReplies: 2Last Post: 01-06-2008, 03:04 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks