Skip to content Skip to sidebar Skip to footer

Best Way To Update Checkbox Prefefences

I was coding a clock for android. For it, i set a function which updates screen 1 time each a second, so my program can consume a lot of resources, and my objective is to add a ch

Solution 1:

if you are using a PreferenceActivity you can implement the OnPreferenceClickListener set a listener on the checkbox then in your onPreferenceClick method with the key you set for the box and do what you need to do with it

@Override
public boolean onPreferenceClick(Preference preference) {
    if (preference.getKey().equals("schedulestart")) {
        showDialog(0);
    } else if (preference.getKey().equals("schedulestop")) {
        showDialog(1);
    } else if (preference.getKey().equals("priority")) {
        // Reset unread count when switching mailboxes. They might differ.
        getPreferenceManager().getSharedPreferences().edit().putInt("unreadcount", 0).commit();
    }
    return true;
}

Post a Comment for "Best Way To Update Checkbox Prefefences"