How to add Title to Spinner in android

I have a problem, I have a spinner design and adding elements (i.e. states) on it. Now I want to show "SELECT STATES" on the main screen only once. When we click on this counter it will hide this text ("SELECT STATES") and should display a list of states.

Thanks at Advance.

+6
source share
3 answers

Easy: spinner.setPrompt ("Name"); or xml: android: prompt = "@ string / title"

+8
source

Here is my favorite solution to the problem - How to make Android Spinner with Select One source code

I am sorry that this is a very long time, so I do not want to reprint it here, please check it here.

The best part is that I was able to use its code without any changes.

+4
source

I don’t think it has such an attribute, even Google uses a text view to show the title in the example: http://developer.android.com/resources/tutorials/views/hello-spinner.html

If you really want to do this, you can add the line "SELECT STATES" to the first slot in the list, and then delete it after selecting the first item.

+3
source

Source: https://habr.com/ru/post/888633/


All Articles