Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Button seleccion;
- TextView respuesta;
- RadioButton rb1, rb2;
- CheckBox cb1, cb2;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- seleccion = (Button)findViewById(R.id.seleccion);
- respuesta = (TextView) findViewById(R.id.respuesta);
- rb1 = (RadioButton) findViewById(R.id.rb1);
- rb2 = (RadioButton) findViewById(R.id.rb2);
- cb1 = (CheckBox) findViewById(R.id.cb1);
- cb2 = (CheckBox) findViewById(R.id.cb2);
- seleccion.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (rb1.isChecked()){
- respuesta.setText(rb1.getText());
- }else if (rb2.isChecked()){
- respuesta.setText(rb2.getText());
- }else if (cb1.isChecked()){
- respuesta.setText(cb1.getText());
- }else if (cb2.isChecked()){
- respuesta.setText(cb2.getText());
- }else{
- respuesta.setText("no ha seleccionado nada");
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement