hello guys i want to change my checked text view to switch preference what methods should i use this is my checked text view method i want to do the same thing but with switch preference
final CheckedTextView cc = (CheckedTextView) findViewById(R.id.checkedTextView);
if (!mysetting.service) {
ctv.setChecked(false);
} else if (mysetting.service) {
ctv.setChecked(true);
}
ctv.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (ctv.isChecked()) {
mysetting.service = false;
ctv.setChecked(false);
Editor editor = PreferenceManager.getDefaultSharedPreferences(MainActivity.this).edit();
editor.putBoolean("service", false);
editor.commit();
return;
}
ctv.setChecked(true);
mysetting.service = true;
editor = PreferenceManager.getDefaultSharedPreferences(MainActivity.this).edit();
editor.putBoolean("service", true);
editor.commit();
}