String rank[] = {"tclub1.png", "tclub2.png", "tclub3.png", "tclub4.png",
"tclub5.png", "tclub6.png", "tclub7.png", "tclub8.png", "tclub9.png",
"tclub10.png", "tclub11.png", "tclub12.png", "tclub13.png"};
Random randInt = new Random();
int b = randInt.nextInt(rank.length);
String d = ("tclub" + b + ".png");
Log.v(LOG_TAG, "in value:=" + d);
以上是代碼。 其實我的數組給我一個(0到12)之間的隨機索引..之後,我將它附加到一個圖像名稱。例如(tclub1.png) 現在它給我的圖像名稱是String fromat。 我如何隨機指定這個圖像?Android隨機
http://stackoverflow.com/questions/3315718/android-random-number – fadden 2010-07-23 19:27:47