I would like to implement a drop down with label “CATEGORY” in android.
Here, when I click on the “CATEGORY” button, then a list should be populated. But, when I select any item in that list, then I dont want to change the label “CATEGORY”.
How to do that?
Once you understand how a spinner works, this becomes easy. 🙂
The spinner uses the
getViewmethod to populate the closed spinner, and thegetDropDownViewmethod to create the dropdown. With this information you can create a custom adapter that can have something other than the current selection showing in the closed view. This also lets you avoid having to have non-data (like the word “CATEGORY”) in your data.A quick example:
The rest of the spinner would function as normal, so you could capture the selection in the
onItemSelectedListener.