use switch in android studio code example
Example 1: switch material android tutorial
switchMaterial.isChecked = true
switchMaterial.setOnCheckedChangeListener { buttonView, isChecked
}
Example 2: android switch on change
mySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
});
Example 3: switch case in android
switch(position) {
case 0:
setContentView(R.layout.xml0);
break;
case 1:
setContentView(R.layout.xml1);
break;
default:
setContentView(R.layout.default);
break;
}