I have an ArrayAdapter
as follows
ArrayAdapter<String>dataAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item);
This is the adapter which I am going to use for my Spinner
.I have value sets (String array) for the Spinner
in my strings.xml
file.
How can I set the <string-array>
in string.xml
to the spinner pragmatically? Please help!
Just add it to your ArrayAdapter when you create it.
String[] yourArray = getResources().getStringArray(R.array.array_name);
ArrayAdapter<String>dataAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item, yourArray);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With