Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to make an Android Spinner with initial text “Select One”
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Heitor Lima  
View profile  
 More options Aug 13 2012, 12:00 pm
From: Heitor Lima <heitorlima...@gmail.com>
Date: Mon, 13 Aug 2012 13:00:20 -0300
Local: Mon, Aug 13 2012 12:00 pm
Subject: How to make an Android Spinner with initial text “Select One”

In Android, I want to use a Spinner that initially (when the user has not
made a selection yet) displays the text "Select One". When the user clicks
the spinner, the list of items is displayed and the user selects one of the
options. After the user has made a selection, the selected item is
displayed in the Spinner instead of "Select One".

I have the following code to create a Spinner:

String[] items = new String[] {"One", "Two", "Three"};
Spinner spinner = (Spinner) findViewById(R.id.mySpinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_it em);
spinner.setAdapter(adapter);

With this code, initially the item "One" is displayed. I could just add a
new item "Select One" to the items, but then "Select One" would also be
displayed in the dropdown list as first item, which is not what I want.

Any ideas? Thanks in advance.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
TreKing  
View profile   Translate to Translated (View Original)
 More options Aug 17 2012, 4:17 am
From: TreKing <treking...@gmail.com>
Date: Fri, 17 Aug 2012 03:17:12 -0500
Local: Fri, Aug 17 2012 4:17 am
Subject: Re: [android-developers] How to make an Android Spinner with initial text “Select One”

On Mon, Aug 13, 2012 at 11:00 AM, Heitor Lima <heitorlima...@gmail.com>wrote:

> With this code, initially the item "One" is displayed. I could just add a
> new item "Select One" to the items, but then "Select One" would also be
> displayed in the dropdown list as first item, which is not what I want.

Unfortunately, that's as good as you're going to get with Spinner. You'll
have to code up your own version or extend the class and add this
functionality.

What I do is add the "Select One" type prompt and just ignore it if that's
what the user selected. Works well enough.

--------------------------------------------------------------------------- ----------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »