Include "Select All Vendors" in Spinner’s first position?

Asked

Viewed 34 times

0

Good morning, everyone,

I have Spinner in which I load the vendor information (user option to select a vendor) I need to include in this Spinner an option to select all vendors and then have the option to select ALL or certain vendor.

I am using the following code, but setPrompt does not work well:

spfor.setPrompt("Todos os Fornecedores");
ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item, forn);
spfor.setAdapter(adapter);

thank you in advance.

1 answer

0

You can create an array file within the values folder with the spinner options and then pass this array in the Arrayadapter constructor

array_gender.xml code

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="array_gender_options">
    <item>@string/TODOS FORNECEDORES</item>
    <item>@string/COCA COLA</item>
    <item>@string/FANTA LARANJA</item>
</string-array>
</resources>

creation code of the arrayAdapter

ArrayAdapter spinnerAdapter = ArrayAdapter.createFromResource(this,
            R.array.array_gender, android.R.layout.simple_spinner_item);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.