Setting the value of the spinner dynamically

android, arrays, eclipse, java, spinner

Solution

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);

Problem

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!

Original source

Related problems