3

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

Sergi Juanola
  • 6,531
  • 8
  • 56
  • 93
  • Why can you not access it from the ListView activity? Can you post some code? And what do you mean by "a button I need to track"? – Jack Aug 03 '11 at 17:02
  • @Jack because I'm not directly getting each item in the list. What I would want is some sort of `itemList.setOnItemButtonClicked...`. However this one is within the ListView, while I need it inside the custom list item view. – Sergi Juanola Aug 03 '11 at 17:07

1 Answers1

1

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.

Community
  • 1
  • 1
Jack
  • 9,156
  • 4
  • 50
  • 75
  • I didn't solve my problem that way, but thanks to your links I kind of managed to do. What I did was event bubbling (in a rudimentary way). I just got the event from the custom view, listened in the adapter and listened again in the list itself. You deserve the points =) – Sergi Juanola Aug 03 '11 at 19:03