简体   繁体   中英

display imageview according to int array

I am trying to generate 5 random dices and then display the corresponding dice image to them but I'm not sure how to do it in a loop.

p1Dice1 = (ImageView) findViewById(R.id.ivDice1);
p1Dice2 = (ImageView) findViewById(R.id.ivDice2);
p1Dice3 = (ImageView) findViewById(R.id.ivDice3);
p1Dice4 = (ImageView) findViewById(R.id.ivDice4);
p1Dice5 = (ImageView) findViewById(R.id.ivDice5);    

for (int i = 0; i < 5; i++) {
diceArray[i] = randomDice.nextInt(6) + 1;
}

I Would like you to go through HashMap, it is the Best Example for your Type.

http://www.java-samples.com/showtutorial.php?tutorialid=369

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM