Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Switch
- android:layout_width="148dp"
- android:layout_height="0dp"
- android:text="New Switch"
- android:id="@+id/switch1"
- android:layout_weight="0.08"
- android:clickable="true"
- />
- Switch toggle = (Switch) findViewById(R.id.switch1);
- toggle.setTextOn("On");
- toggle.setTextOff("Off");
- toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if (isChecked) {
- // The toggle is enabled
- } else {
- // The toggle is disabled
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement