The switch control used in the android development tutorial
- 2020-06-01 10:58:21
- OfStack
<Switch
android:id="@+id/open"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textOff=" Bluetooth off "
android:textOn=" Bluetooth on " />
open.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
mBluetoothAdapter.enable();// Open the bluetooth
} else {
mBluetoothAdapter.disable();// Close the bluetooth
}
}
});