表达式的类型必须是数组类型,但它解析为int

时间:2012-02-06 03:56:15

标签: java android arrays

我在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);

1 个答案:

答案 0 :(得分:1)

你可能想要这样的东西:

String openClass = getResources().getStringArray(R.array.calc_categories)[position]