give each place in array randomaly button-android -
i need idea of how randomaly give each button[i] on of values r.id.buttonj_mg. (one 1 function...). don't know how since r.id.button1_mg not string, can't somethink r.id.button+j+_mg when j chossen randomaly..
this situation now:
button[1]= (button)findviewbyid(r.id.button1_mg); button[2]= (button)findviewbyid(r.id.button2_mg); button[3]= (button)findviewbyid(r.id.button3_mg); button[4]= (button)findviewbyid(r.id.button4_mg); button[5]= (button)findviewbyid(r.id.button5_mg); button[6]= (button)findviewbyid(r.id.button6_mg); button[7]= (button)findviewbyid(r.id.button7_mg); button[8]= (button)findviewbyid(r.id.button8_mg); button[9]= (button)findviewbyid(r.id.button9_mg); button[10]= (button)findviewbyid(r.id.button10_mg); button[11]= (button)findviewbyid(r.id.button11_mg); button[12]= (button)findviewbyid(r.id.button12_mg); button[13]= (button)findviewbyid(r.id.button13_mg); button[14]= (button)findviewbyid(r.id.button14_mg); button[15]= (button)findviewbyid(r.id.button15_mg); button[16]= (button)findviewbyid(r.id.button16_mg);
you use collection store ints integers , use java collection class shuffle() method on objects. remove them 1 one collection in each 1 of buttons.
list<integer> resources = new arraylist<integer>(); ... resources.add(r.id.button1); ... collections.shuffle(resources);
Comments
Post a Comment