문제

My array with the images stored in:

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};

Getting the error with: image.setImageResource(image[count + 1]); But it works with the commented out code!

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!");}
도움이 되었습니까?

해결책

You have a name clash, that is, you have two things with a same name:

int image[] = ...

and

ImageView image = ...

Rename either of them.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top