ImageView
으로로드 할 랜덤 애니메이션을 생성하려고합니다. 그것은 효과가 있지만 때로는. 3 개의 애니메이션이 선택되면 ArrayIndexOutOfBoundsException
이 표시되며 이유는 확실하지 않습니다. 예외를 잡으면 3 개의 애니메이션이 무작위로 선택되고 아무 것도로드되지 않습니다.랜덤 애니메이션을 생성하는 중 문제가 발생했습니다.
final int[] anim = { R.anim.anim_0, R.anim.anim_1, R.anim.anim_2,
R.anim.anim_3, R.anim.anim_4, R.anim.anim_5 };
Random ran = new Random();
int i = ran.nextInt(6 - 1);
mAlbum.startAnimation(AnimationUtils.loadAnimation(
getBaseContext(), anim[i++]));
왜 'i ++'가 있습니까? – AppleGrew