In my app I have a spinner in which the user selects a number. I have tried the following, and it works, but it requires a string-array
in the values.XML file,which is impractical for me as I have several of these with differing ranges (between 80-100 items long).
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.number_array, android.R.layout.simple_spinner_item);
spinner.setAdapter(adapter);
This works, but it requires this;
<string-array name="number_array">
<item>1</item>
.....
</string-array>
So I have created an int array instead -
int [] intArray = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
But creating an array adapter like this doesn't work
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
intArray, android.R.layout.simple_spinner_item);
Is there any way to do this or am I stuck with a lot of long numerical string-arrays
in my values.xml file?