Example usage for android.preference CheckBoxPreference CheckBoxPreference

List of usage examples for android.preference CheckBoxPreference CheckBoxPreference

Introduction

In this page you can find the example usage for android.preference CheckBoxPreference CheckBoxPreference.

Prototype

public CheckBoxPreference(Context context, AttributeSet attrs) 

Source Link

Usage

From source file:com.adam.aslfms.MusicAppsActivity.java

private void update() {
    mSupportedMusicAppsList.removeAll();
    mPrefsToMapisMap.clear();//w  w w.j a v a  2s  .  c om
    mMapisToPrefsMap.clear();

    MusicAPI[] mapis = MusicAPI.all(this);
    for (MusicAPI mapi : mapis) {
        CheckBoxPreference appPref = new CheckBoxPreference(this, null);
        appPref.setTitle(mapi.getName());
        appPref.setPersistent(false);
        appPref.setChecked(mapi.isEnabled());

        mSupportedMusicAppsList.addPreference(appPref);
        mPrefsToMapisMap.put(appPref, mapi);
        mMapisToPrefsMap.put(mapi, appPref);
        setSMASummary(appPref, mapi);
    }

    // explanation text, for what this screen does
    Preference detect = new Preference(this);
    if (mapis.length == 0)
        detect.setTitle(R.string.no_supported_mapis_title);
    else if (mapis.length == 1)
        detect.setTitle(R.string.find_supported_mapis_one_title);
    else
        detect.setTitle(getString(R.string.find_supported_mapis_many_title).replace("%1",
                Integer.toString(mapis.length)));
    detect.setSummary(R.string.find_supported_mapis_summary);
    mSupportedMusicAppsList.addPreference(detect);
}