0

When I define a Spinner widget, the text that shows on the widget area on the screen is always the 1st entry defined for the Spinner options. I'd like to be able to set it to a specific value, one that is in line with the title of the Spinner popup which is subsequently displayed (per android:prompt).

The only other option I see is to make the

Is there some widget option I'm missing that lets you specify what you want displayed on the screen for the name where the

charlest
  • 925
  • 2
  • 10
  • 20

2 Answers2

1

Did u tried using setSelection() method?? Here is a similar question.

Community
  • 1
  • 1
Teja Kantamneni
  • 17,402
  • 12
  • 56
  • 86
  • That's a slightly different issue. I'm referring to the string displayed in the tag: I'd like it to be the description of what the spinner selection values represent. My other option is to put a TextField above the Spinner tag with a description of what the Spinner is for, but I'd like to find some option to define what always appears in the – charlest Jun 21 '11 at 12:15
1

Why not just add the title as the first option in the list. You'll have to add logic to check for an un-answered question but that's not a big deal...

Travis
  • 3,737
  • 1
  • 24
  • 24
  • Here's what I did to get it to work. It incorporates the 1st part of what you wrote, and then adds a part. It's pretty much a hack, but it does work. – charlest Jun 21 '11 at 17:55
  • 1) Define the 1st entry of the String array as you mentioned to be the title I want to be displayed on the screen when the widget is first display. This array is the array you specify in the statement: ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, stringArrayOfValues); – charlest Jun 21 '11 at 17:56
  • 2) In the private class private class SomeListener implements OnItemSelectedListener, in both the methods (onItemSelected and onNothingSelected), the first statemnt in the method sets stringArrayOfValues[0] to be the value you want to show as the 1st choice in the list of selection items which pop up. – charlest Jun 21 '11 at 17:56