回答編集履歴
1
間違い訂正&個人的に見づらいので整理
test
CHANGED
@@ -6,25 +6,37 @@
|
|
6
6
|
|
7
7
|
for(ImageView tmp : Arrays.asList(gat, gat2, gat3, gat4, gat5, gat6)) {
|
8
8
|
|
9
|
+
//各ImageViewに対して乱数を振り、その結果でDrawableを取り出す配列を決定
|
10
|
+
|
9
11
|
gatya2 = r.nextInt(100);
|
12
|
+
|
13
|
+
TypedArray array = null;
|
10
14
|
|
11
15
|
if(gatya2 <= 2){
|
12
16
|
|
13
|
-
|
17
|
+
array = images4;
|
14
18
|
|
15
19
|
}else if(gatya2 <= 12){
|
16
20
|
|
17
|
-
|
21
|
+
array = images3;
|
18
22
|
|
19
23
|
}else if(gatya2 <= 39){
|
20
24
|
|
21
|
-
|
25
|
+
array = images2;
|
22
26
|
|
23
27
|
}else{
|
24
28
|
|
25
|
-
|
29
|
+
array = images;
|
26
30
|
|
27
31
|
}
|
32
|
+
|
33
|
+
//決定した配列の長さから乱数を生成し,それをインデックスにDrawableを取り出しセット
|
34
|
+
|
35
|
+
//(ここは個人的に括弧が重なりすぎて読みにくかったため分解)
|
36
|
+
|
37
|
+
int i = r.nextInt(array.length());
|
38
|
+
|
39
|
+
tmp.setImageDrawable(array.getDrawable(i));
|
28
40
|
|
29
41
|
}
|
30
42
|
|