I have an Android Spinner view in my layout. I would like that spinner to show only a single text item when closed, but when the user clicks on it (i.e. opens the spinner dialog) I would like to show more extensive information for each item, including an icon and an additional description text view. As it is now the spinner shows the very same layout (icon, title + description) in both states.
If I attach an ArrayAdapter to the spinner, then I get access to something called "setDropDownViewResource" but that's not necessarily what I need, since my spinner data is fetched from a Cursor not from an Array of any kind (I have, as of now, created my own adapter, extending BaseAdapter).
Anyone who can help me?
You have to create a custom Adapter
class for the Spinner and overwrite the two methods getView()
for the normal closed view and getDropDownView()
for the drop down list view. Both methods must return a View
object for a single element.
Have a look at this tutorial it might help you getting started.