Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <Switch
  2. android:layout_width="148dp"
  3. android:layout_height="0dp"
  4. android:text="New Switch"
  5. android:id="@+id/switch1"
  6. android:layout_weight="0.08"
  7. android:clickable="true"
  8. />
  9.  
  10. Switch toggle = (Switch) findViewById(R.id.switch1);
  11. toggle.setTextOn("On");
  12. toggle.setTextOff("Off");
  13. toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  14. public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  15. if (isChecked) {
  16. // The toggle is enabled
  17. } else {
  18. // The toggle is disabled
  19. }
  20. }
  21. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement