Reputation:
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);
}
How can I assign a variable to choiceButton1, choiceButton2, choiceButton3, and choiceButton4? Is it possible to have one variable that holds the four buttons with setX and setY data?
Upvotes: 1
Views: 1345
Reputation: 68
choiceButton1.setTag(value);
will be useful for you
you can retrieve data by calling getTag
Upvotes: 1