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

时间:2014-05-13 13:54:27

标签: java android imageview android-imageview

我的数组中存储的图像为:

int image[] = {R.drawable.natsu, R.drawable.erza, R.drawable.gray, R.drawable.lucy, R.drawable.gajeel, R.drawable.juvia, R.drawable.laxus, R.drawable.jellal, R.drawable.cana, R.drawable.mira, R.drawable.elfman, R.drawable.wendy, R.drawable.lisanna, R.drawable.gildarts, R.drawable.makarov, R.drawable.mavis};

获取错误:image.setImageResource(image [count + 1]); 但它适用于注释掉的代码!

if(compare.equals(ans)){
Toast.makeText(getApplicationContext(), "Correct!", Toast.LENGTH_LONG).show();
//RelativeLayout relative = (RelativeLayout) findViewById(R.id.relative);
//relative.setBackgroundResource(image[count+1]);
ImageView image = (ImageView) findViewById(R.id.iVAnim);
image.setImageResource(image[count + 1]);

et.setText("");
points = points + 10;

point.setText("You have " + points + " points!");}

1 个答案:

答案 0 :(得分:1)

你有一个名字冲突,也就是说,你有两件同名的东西:

int image[] = ...

ImageView image = ...

重命名其中任何一个。