Digamos que tengo un par de botones en un LinearLayout, 2 de ellos son:Android: ¿Utiliza una instrucción SWITCH con setOnClickListener/onClick para más de 1 botón?
mycards_button = ((Button)this.findViewById(R.id.Button_MyCards));
exit_button = ((Button)this.findViewById(R.id.Button_Exit));
me registro setOnClickListener()
en ambos:
mycards_button.setOnClickListener(this);
exit_button.setOnClickListener(this);
¿Cómo hago un interruptor para diferenciar entre la dos botones dentro de Onclick?
public void onClick(View v) {
switch(?????){
case ???:
/** Start a new Activity MyCards.java */
Intent intent = new Intent(this, MyCards.class);
this.startActivity(intent);
break;
case ???:
/** AlerDialog when click on Exit */
MyAlertDialog();
break;
}
prefiero no usar menús para esto, ya que puede poner los botones en cualquier lugar que desee a la presentación ... – Hubert