Android Spinner Invitation

I have a problem with android:prompt for counter. I used this code in an XML file, but it does not work:

 <Spinner android:id="@+id/spinner" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="120dp" android:prompt="@string/club_type"> </Spinner> 

I also tried to use this code in my main activity, but this also does not work:

 spinner.setPrompt("Select club"); 

While I used the second case, I did not use android:prompt ; in other words, I tried them individually. Can someone help me?

+7
android android spinner
source share
2 answers

Works well on mine.

You accept the invitation using the first element. Click on the counter and you will see Select club as the title, which is an invitation.

Hope this helps.

+6
source share

There are two ways to deal with this:

Static path:

add one line code in XML Spinner tag

 android:spinnerMode="dialog" 

and then install:

 android:prompt="PROMPT" 

Dynamically:

use

 Spinner spinner = (Spinner)findViewById(R.id.spnner); String[] myItems= getResources().getStringArray(R.array.spinner1); ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this, android.R.layout.select_dialog_item, myItems); spinner.setPrompt("PROMPT"); 

when configuring and initializing the adapter

Hope this can help you! :)

+6
source share

All Articles