Sergi Juanola
Sergi Juanola

Reputation: 6647

Custom Listener for a ListView item

I have a View with a ListView appended, which actually uses a custom view item done programatically. Inside each list item I have a button which I need to track, to update another item in the view. It is only invalidated when you click on the list item button, not anywhere else in the list item.

So I thought of creating a custom Listener. I trigger it when the button is clicked, but I have no way to access it from the ListView activity.

Is there a way to simulate those setOnItem...Listener's using a custom listener? Thanks in advance

Upvotes: 3

Views: 1670

Answers (1)

Jack
Jack

Reputation: 9242

Please see this link to help with how to set onClickListener from within custom ListAdapters.

You can use the myButton.getTag() and myButton.setTag() to put and get data to/from your View/Button.

See this link as well to help with custom ListAdapters.
Here is another good example I found of how to use a custom adapter.

Upvotes: 1

Related Questions