RadioButton
Enviado por PedroKool • 22 de Noviembre de 2015 • Apuntes • 704 Palabras (3 Páginas) • 104 Visitas
public class MainActivity extends ActionBarActivity {
private MediaPlayer mp;
private ImageButton bt1,bt2,bt3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final RadioButton rab1 = (RadioButton) findViewById(R.id.radioButton);
final RadioButton rab2 = (RadioButton) findViewById(R.id.radioButton2);
final RadioButton rab3 = (RadioButton) findViewById(R.id.radioButton3);
rab1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast msg = Toast.makeText(getBaseContext(), "Correcto",
Toast.LENGTH_SHORT);
msg.show();
}
});
rab2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast msg = Toast.makeText(getBaseContext(), "Incorrecto,intenta otra vez",
Toast.LENGTH_SHORT);
msg.show();
}
});
rab3.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast msg = Toast.makeText(getBaseContext(), "Incorrecto,intentalo de nuevo",
Toast.LENGTH_SHORT);
msg.show();
}
});
bt1 = (ImageButton) findViewById(R.id.imageButton);
bt1.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view){
mp= MediaPlayer.create(MainActivity.this, R.raw.over);
mp.start();
}
});
bt2 = (ImageButton) findViewById(R.id.imageButton2);
bt2.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view){
mp=MediaPlayer.create(MainActivity.this, R.raw.estrella);
mp.start();
}
});
bt3 = (ImageButton) findViewById(R.id.imageButton3);
bt2.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view){
mp=MediaPlayer.create(MainActivity.this, R.raw.stage);
mp.start();
}
});
}
}
...