Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Title in Spinner in android [duplicate]

Tags:

android

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.

like image 949
Himanshu Avatar asked May 20 '11 11:05

Himanshu


2 Answers

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

like image 104
GeX Avatar answered Sep 28 '22 05:09

GeX


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.

like image 35
kaitik Avatar answered Sep 28 '22 05:09

kaitik