我在Android应用中遇到以下错误:
表达式的类型必须是数组类型,但它已解析为int
protected void onListItemClick(ListView lv, View v, int position, long id) {
super.onListItemClick(lv, v, position, id);
String openClass = R.array.calc_categories[position]; //error on this line
try {
Class selected = Class.forName("com.calculator.commonCalculatios." + openClass);
Intent selectedIntent = new Intent(this, selected);
startActivity(selectedIntent);
答案 0 :(得分:1)
你可能想要这样的东西:
String openClass = getResources().getStringArray(R.array.calc_categories)[position]