Include "Select All Suppliers" in the top position of Spinner?

0

Good morning,

I have Spinner in which I load the information of the suppliers (option for user to select a supplier), I need that in that Spinner to be included an option to select all the suppliers and there to be able to select ALL or a certain supplier. >

I'm 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.

    
asked by anonymous 21.05.2017 / 18:48

1 answer

0

You can create an array file within the values folder with the spinner options and then pass that array into 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>

ArrayAdapter creation code

ArrayAdapter spinnerAdapter = ArrayAdapter.createFromResource(this,
            R.array.array_gender, android.R.layout.simple_spinner_item);
    
21.05.2017 / 19:42