Pre-API Level 14 there is no switch preference. If I use preferences.xml to create my preference screen is there some way to distinguish between the API levels? So having a
you can use SwitchCompat:
on setOnCheckedChangeListener:
SwitchCompat switchCompat = (SwitchCompat)convertView.findViewById(R.id.switch_compat);
switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
textView.setText("check");
} else {
textView.setText("unCheck");
}
}
});
i hope help you.