The switch control used in the android development tutorial
<Switchandroid: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() {@Overridepublic void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {if (isChecked) { mBluetoothAdapter.enable();// Open the bluetooth} else { mBluetoothAdapter.disable();// Close the bluetooth}}});