Search code examples
androidlistviewlistenerspinnercustom-adapter

OnItemClickListener() for spinners in each item of a list view


I have a list view with its own custom adapter and I have put a spinner in every item of that list view but the problem is, the items are added by the user so i don't know how to catch it when he makes a selection in the spinners.

PS. i have put a spinner in every item of that list view but i don't know how to listen for selections in those inner spinners.

So do i put the onIitemClickListener inside the GetView() of the custom adapter or in the MainActivity()'s onCreate function?

The spinner does have an id but since i'm using a custom list view, each spinner is almost as if all have the same id unless i specify the item of the list view inside the GetView() but even then is it possible to put a listener inside getView() and have it running 24/7?

Thanks in advance!


Solution

  • You should add the OnItemClickListener inside the OnCreate() method using GetView(). You don't nessecarily need an id as long as you are using GetView() correctly. There is also an OnItemSelectedListener that you can use if you want to. You can learn more about it here.

    Hope this helps!