0

I have a listView using a custom adapter. Each row contains a button and some other Views. I want to be able to click either on the button, or on the row itself (to edit the item of the list that is clicked).

Setting an onItemClickListener in the activity won't work because of this problem

I think I have to set an onClickListener in the getView() method of my adapter for it to work properly. I would like to use my activity's onClickListener, in order to use a startActivityForResult() when the row is clicked, in order to have something returned to my activity when the item edition activity is over. How can I do that?

Thanks!

Community
  • 1
  • 1
nbarraille
  • 9,926
  • 14
  • 65
  • 92

1 Answers1

0

You'll need to add an onclick listener to every button you add to every row. The best way to do this is probably to make your own custom layout in code, and every time you create a new view in your adapter, set the onclick listener in the layout code.

Falmarri
  • 47,727
  • 41
  • 151
  • 191
  • 1
    So my custom layout class has to extend and to implement OnClickListener, right? How can I do a startActivityForResult() from another class, so I can return an object to my main Activity? I can only access view.getContext().startActivity(), and not startActivityForResult() – nbarraille Nov 02 '10 at 01:54