-2

I was trying to set prompt in Spinner in android,over dynamically add data in spinner.Firstly, I have used spinner.setPrompt(" Branch List ") but couldn't set it in spinner. though my this line of code is wroking. But still didn't get it done.and then I used second method which is as follows:

I here by share my code of xml which is second method that I've used for setting prompt.

MainActivity.xml

        <Spinner
            android:layout_width="250dp"
            android:layout_height="wrap_content"
            android:id="@+id/branchSpinner"
            android:spinnerMode="dropdown"
            android:prompt="@string/Branch"
            />

Stings.xml

<string name="Branch">Branch</string>
example one
  • 19
  • 1
  • 1
  • 9
  • Question is slimier to [https://stackoverflow.com/questions/867518/how-to-make-an-android-spinner-with-initial-text-select-one](https://stackoverflow.com/questions/867518/how-to-make-an-android-spinner-with-initial-text-select-one) – PCGALI ANDROID Aug 02 '17 at 05:56

1 Answers1

1

You have to use android:spinnerMode="dialog" if u want to show prompt using spinner.

           <Spinner
            android:layout_width="250dp"
            android:layout_height="wrap_content"
            android:id="@+id/branchSpinner"
            android:spinnerMode="dialog"
            android:prompt="@string/Branch"
            />
Akshay Chopde
  • 670
  • 4
  • 10
  • But I don't want it as Dialog.I want If none item is selected then it will show the prompt text in my spinner which isn't visible in my arraylist added to spinner. – example one Aug 02 '17 at 05:58
  • android:spinnerMode only works in dialog mode not in dropdown mode. – Akshay Chopde Aug 02 '17 at 06:00
  • Thanks for your help @Akshay but I have followed different method bacuse what i want is couldn't acheived by this – example one Aug 02 '17 at 06:33