gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 12:59:28 27 4
gpt4 key购买 nike

我的数组,图像存储在:

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!");}

最佳答案

您有名称冲突,也就是说,您有两个同名的东西:

int image[] = ...

ImageView image = ...

重命名其中一个。

关于java - 表达式的类型必须是数组类型,但它解析为 Imageview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23633240/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com