关于TypedArray 获取TypedArry

about TypedArray obtainTypedArry

这两行是我写的:

final  String[] options = res.getStringArray(breakFastNames);
final  TypedArray icons = res.obtainTypedArray(R.array.breakFastIcons);

第一个正在运行。但是当我把它放在 putExtra:

里面时,第二个给出了一个错误
mIntent.putExtra("OPTIONS",options[i]);
mIntent.putExtra("ICONS", icons[i]);

如果有人能够解决这个问题,我们将不胜感激。

A TypedArray 是 class TypedArray 的实例,它不是 Java 数组,因此您不能使用 [i].

假设 iconsDrawable 的数组,请改用:

mIntent.putExtra("OPTIONS",options[i]);
mIntent.putExtra("ICONS", icons.getDrawable(i));