I have created my application by populating spinners within my Java code. I am now trying to convert it to populating my Spinners from my strings.xml file. I have followed a few websites( example 1 and example 2 ), but have not been able to get my code to work.
The main problem with those is that the ArrayAdapter's they use are of type <CharSequence>. Can I do this somehow using <String> ArrayAdapters?
This is my array in my XML file :
<string-array name="anti_pump_ap_mode_array">
<item>OFF</item>
<item>Anti-Pump</item>
<item>Motor Cut...</item>
</string-array>
Here is the code I've tried :
apModeAdapter = new ArrayAdapter<String>(this, R.array.anti_pump_ap_mode_array, android.R.layout.simple_spinner_item );
apModeAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, R.array.anti_pump_ap_mode_array );
apModeAdapter = ArrayAdapter.createFromResource(this, android.R.layout.simple_spinner_item, R.array.anti_pump_ap_mode_array );
Of course the last one gives me an error, but the first two just do not populate my spinner. When I run the application the Spinner is just empty.