This is for Android, but I believe it's a general Java question, so I'm labelling it as such.
I'm trying to use reflection on R.array to get an array from the list. The arrays are named stringArraySubCategoryX where X is replaced with a number from 0 to 20. This is my code, but I ran into a problem:
Field subCatField = R.array.class.getField("stringArraySubCategory" + position);
subCatergorySpinner.setAdapter(ArrayAdapter.createFromResource(InfoActivity.this, subCatField.getInt(R.array), android.R.layout.simple_spinner_item));
The problem part is the subCatField.getInt(R.array) bit, which is supposed to return the resource int value of the selected array. But Field.getInt(arg)'s argument is an Object. I checked R.array, and that says public static final class array, but it seems that it's not accepted.
What am I doing wrong?