android: Call method on Click of a TableRow
I have a TableLayout in the xml that has a row. I am adding more rows to the table dynamically. How do I call a function onclick of the rows added dynamically. I could do the same for the exsisting row in xml by adding android:onclick="RowClicked" and it calls RowClicked method. I want to call th开发者_如何学Ce same method for the dynamcally added rows to the Table. How do I achieve that ? I can setOnClickListener(this) and it works, but I want to call the method.
If the above is not possible, then in OnClick() how can I know that the component that caused event is a TableRow. I mean something like view.instanceOf(TableRow) or similar can help me know that the TableRow is clicked and can handle from their.
Any one possiibility from the above 2 can help me resolve my problem. Any help, guidance is highly appreciated.
Thanks
try to handle on click event of the row inside the loop where you are adding dynamic rows. or try to set tag to each row when adding dynamic rows and on click listener use .getTag method
精彩评论