开发者

How to add Title in Spinner in android [duplicate]

This question already has answers here: How to make an Android Spinner with initia开发者_如何学Cl text "Select One"? (36 answers) Closed 9 years ago.

I have a problem I have design a spinner and add items(i.e. states) on it. Now I want to show "SELECT STATES" on main Screen only once. When we click on that spinner it will hide this text("SELECT STATES") and should show the list of the states.

Thanks in Advance.


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


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

If you really want to do it that way, you can add the String "SELECT STATES" in the first slot of the list, and then remove it after the first item selection.


Here is my favourite solution to the problem - How to make an Android Spinner with initial text “Select One”

I'm sorry it is very long, so I'm not keen to repost it here again - please check it out on the link.

The nice part is that I was able to use his code without any changes at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜