I wrote those two lines :
final String[] options = res.getStringArray(breakFastNames);
final TypedArray icons = res.obtainTypedArray(R.array.breakFastIcons);
The first one is working. But the second one is giving an error when I put it inside putExtra
:
mIntent.putExtra("OPTIONS",options[i]);
mIntent.putExtra("ICONS", icons[i]);
Kindly if someone is able to solve this issue, that will be strongly appreciated.
A TypedArray
is an instance of the class TypedArray
, it is not a Java array, so you cannot reference a single value of the array using [i]
.
Assuming that icons
is an array of Drawable
, use this instead:
mIntent.putExtra("OPTIONS",options[i]);
mIntent.putExtra("ICONS", icons.getDrawable(i));