有这样的代码:
case R.id.button:
int id=randImage();
imgView1.setImageResource(id);
public int randImage() {
Random rand= new Random();
int randomNumber=rand.nextInt(24)+1;
String randomImage="img"+randomNumber;
int id = getResources().getIdentifier(randomImage, "drawable", getPackageName());
return id;
}
case R.id.imgView1:
Intent i= new Intent();
i.putExtra("imgId", id); //IS UNREACHABLE
设置后如何获得可绘制的ID?