Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set a title for spinner which is not selectable..? [duplicate]

Tags:

android

I have spinner but in it only selectable items are shown as default title..

is there any way i can set title which doesn't appear when spinner unfolds...

like image 454
ngesh Avatar asked Jun 17 '11 12:06

ngesh


People also ask

How to set a title for spinner which is not selectable?

You will have to set the prompt attribute of spinner. spinner. setPrompt("Title");

Which of the following look like a dropdownlist in android?

Android Spinner is just a drop down list similar to what's seen in other programming languages such as in HTML pages. In Android, Spinner is used to select one value from a set of values. In the default state, a spinner shows its currently selected value.


1 Answers

You will have to set the prompt attribute of spinner.

<Spinner   android:id="@+id/discuss_about_spinner"  
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content"
           android:prompt="@string/discuss_about_header"
           android:layout_below="@+id/what_time_layout">
</Spinner>

Programmatically set title to Spinner

spinner.setPrompt("Title");

I don't know what the reason is, prompt don't support direct substitution of a string value. Instead you must have your string in strings.xml.

like image 113
Andro Selva Avatar answered Oct 19 '22 05:10

Andro Selva