public void allButtonChoice(){
Button[] multiChoice = new Button[3];
multiChoice = new Button[]{choiceButton1,choiceButton2,choiceButton3,choiceButton4};
//to output shuffled array in an randomized order.
//Random number generator.
Random generateMultiChoice = new Random();
for(int i = 0; i < multiChoice.length; i++){
int randomPosition = generateMultiChoice.nextInt(multiChoice.length);
Button temp = multiChoice[i];
multiChoice[i] = multiChoice[randomPosition];
multiChoice[randomPosition] = temp;
}
//set the positions to the buttons in order
choiceButton1.setX(10f);
choiceButton1.setY(10f);
choiceButton2.setX(10f);
choiceButton2.setY(10f);
choiceButton3.setX(10f);
choiceButton3.setY(12f);
choiceButton4.setX(10f);
choiceButton4.setY(12f);
}
如何为choiceButton1,choiceButton2,choiceButton3和choiceButton4分配变量?是否可以使用一个变量来保存包含setX和setY数据的四个按钮?
答案 0 :(得分:1)
choiceButton1.setTag(值);
对你有用
您可以通过调用getTag
来检索数据