Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/12/2012, 10:45
Avatar de zupadin
zupadin
 
Fecha de Ingreso: abril-2012
Mensajes: 6
Antigüedad: 12 años
Puntos: 1
Botones en Android

Hola señores,miren quiero hacer lo siguiente, coger todos los botones que tengo en la vista y con un random cambiarle el fondo del botón pues yo hago lo siguiente pero esto no funciona, haber si alguien me hecha una mano, aquí el codigo:

//CARGAR EL ARRAY CON LOS BOTONES
botones[0] = (Button)findViewById(R.id.button1);
botones[1] = (Button)findViewById(R.id.button2);
botones[2] = (Button)findViewById(R.id.button3);
botones[3] = (Button)findViewById(R.id.button4);
botones[4] = (Button)findViewById(R.id.button5);
botones[5] = (Button)findViewById(R.id.button6);
botones[6] = (Button)findViewById(R.id.button7);
botones[7] = (Button)findViewById(R.id.button8);
botones[8] = (Button)findViewById(R.id.button9);

//RELLENAR BOTONES
for(int i=0;i<botones.length;i++)
{
i=num.nextInt();
botones[i].setBackgroundResource(R.drawable.topo);
}