我的 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);
最佳答案
你可能想要这样的东西:
String openClass = getResources().getStringArray(R.array.calc_categories)[position]
关于java - 表达式的类型必须是数组类型,但它解析为 int,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9155423/