Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to display as "Please Select" in Spinner before selecting a value. After selecting a value it should disappear [duplicate]

I'm using Spinner to select a value from the drop down menu. I want initially to be displayed as "Please Select", after selecting a value it should disappear. I'm using the following code,

UPanelID = (Spinner) findViewById(R.id.spinner1);
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, data);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
UPanelID.setAdapter(dataAdapter);
UPanelID.setOnItemSelectedListener(typeSelectedListener);

data is a String array

like image 335
Krishna Avatar asked Dec 08 '25 21:12

Krishna


1 Answers

You can do this by setting android:prompt="Please Select" attribute in Spinner in your xml file.

Or, you can see following example for making the first item in the Spinner "Please Select":

http://b2creativedesigns.comuv.com/Spinner.html

like image 98
ρяσѕρєя K Avatar answered Dec 10 '25 09:12

ρяσѕρєя K



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!