Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. Button seleccion;
  2. TextView respuesta;
  3. RadioButton rb1, rb2;
  4. CheckBox cb1, cb2;
  5.  
  6.  
  7.  
  8. @Override
  9. protected void onCreate(Bundle savedInstanceState) {
  10. super.onCreate(savedInstanceState);
  11. setContentView(R.layout.activity_main);
  12.  
  13. seleccion = (Button)findViewById(R.id.seleccion);
  14. respuesta = (TextView) findViewById(R.id.respuesta);
  15. rb1 = (RadioButton) findViewById(R.id.rb1);
  16. rb2 = (RadioButton) findViewById(R.id.rb2);
  17. cb1 = (CheckBox) findViewById(R.id.cb1);
  18. cb2 = (CheckBox) findViewById(R.id.cb2);
  19.  
  20. seleccion.setOnClickListener(new View.OnClickListener() {
  21. @Override
  22. public void onClick(View v) {
  23. if (rb1.isChecked()){
  24. respuesta.setText(rb1.getText());
  25. }else if (rb2.isChecked()){
  26. respuesta.setText(rb2.getText());
  27. }else if (cb1.isChecked()){
  28. respuesta.setText(cb1.getText());
  29. }else if (cb2.isChecked()){
  30. respuesta.setText(cb2.getText());
  31. }else{
  32. respuesta.setText("no ha seleccionado nada");
  33. }
  34. }
  35. });
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement