Guest User

Untitled

a guest
Nov 18th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. theSwtch = (Switch)findViewById(R.id.theSwtch);
  2. theSwtch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  3. public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  4.  
  5. Double someNumber = Double.parseDouble(editTextInput.getText().toString());
  6. if (theSwtch.isChecked()){
  7. theSwtch.setText("Weekly");
  8. switcher = true;
  9. someNumber = someNumber/2;
  10. editTextInput.setText(someNumber.toString());
  11. } else if (!theSwtch.isChecked()) {
  12. theSwtch.setText("Bi-Weekly");
  13. switcher = false;
  14. someNumber = someNumber*2;
  15. editTextInput.setText(someNumber.toString());
  16. }
  17. // do something, the isChecked will be
  18. // true if the switch is in the On position
  19. }
  20. });
Add Comment
Please, Sign In to add comment