當前位置: 首頁>>代碼示例>>Java>>正文


Java CheckBoxPreference類代碼示例

本文整理匯總了Java中android.support.v7.preference.CheckBoxPreference的典型用法代碼示例。如果您正苦於以下問題:Java CheckBoxPreference類的具體用法?Java CheckBoxPreference怎麽用?Java CheckBoxPreference使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CheckBoxPreference類屬於android.support.v7.preference包,在下文中一共展示了CheckBoxPreference類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreatePreferences

import android.support.v7.preference.CheckBoxPreference; //導入依賴的package包/類
@Override
public void onCreatePreferences(Bundle bundle, String s) {
    // Add 'general' preferences, defined in the XML file
    addPreferencesFromResource(R.xml.pref_general);

    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
    PreferenceScreen prefScreen = getPreferenceScreen();
    int count = prefScreen.getPreferenceCount();
    for (int i = 0; i < count; i++) {
        Preference p = prefScreen.getPreference(i);
        if (!(p instanceof CheckBoxPreference)) {
            String value = sharedPreferences.getString(p.getKey(), "");
            setPreferenceSummary(p, value);
        }
    }
}
 
開發者ID:rashikaranpuria,項目名稱:ubiquitous,代碼行數:17,代碼來源:SettingsFragment.java

示例2: onSharedPreferenceChanged

import android.support.v7.preference.CheckBoxPreference; //導入依賴的package包/類
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Activity activity = getActivity();

    if (key.equals(getString(R.string.pref_location_key))) {
        // we've changed the location
        // Wipe out any potential PlacePicker latlng values so that we can use this text entry.
        SunshinePreferences.resetLocationCoordinates(activity);
        SunshineSyncUtils.startImmediateSync(activity);
    } else if (key.equals(getString(R.string.pref_units_key))) {
        // units have changed. update lists of weather entries accordingly
        activity.getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    }
    Preference preference = findPreference(key);
    if (null != preference) {
        if (!(preference instanceof CheckBoxPreference)) {
            setPreferenceSummary(preference, sharedPreferences.getString(key, ""));
        }
    }
}
 
開發者ID:rashikaranpuria,項目名稱:ubiquitous,代碼行數:21,代碼來源:SettingsFragment.java

示例3: onCreatePreferences

import android.support.v7.preference.CheckBoxPreference; //導入依賴的package包/類
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    addPreferencesFromResource(R.xml.pref_app);


    /* Get the preference screen, get the number of preferences and iterate through
       all of the preferences if it is not a checkbox preference, call the setSummary method
       passing in a preference and the value of the preference*/

    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    int prefCount = preferenceScreen.getPreferenceCount();

    for (int i = 0; i < prefCount; i++) {
        Preference p = preferenceScreen.getPreference(i);
        if (!(p instanceof CheckBoxPreference)) {
            String value = sharedPreferences.getString(p.getKey(), "");
            setPreferenceSummary(p, value);
        }
    }
}
 
開發者ID:RobIsr,項目名稱:OneMoreRepFitness,代碼行數:22,代碼來源:SettingsFragment.java

示例4: onCreatePreferences

import android.support.v7.preference.CheckBoxPreference; //導入依賴的package包/類
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    addPreferencesFromResource(R.xml.preferences);

    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
    PreferenceScreen prefScreen = getPreferenceScreen();
    int count = prefScreen.getPreferenceCount();


    // Go through all of the preferences, and set up their preference summary.
    for (int i = 0; i < count; i++) {
        Preference p = prefScreen.getPreference(i);
        //don't need to set up preference summaries for checkbox preferences because
        // they are already set up in xml using summaryOff and summary On
        if (!(p instanceof CheckBoxPreference)) {
            String value = sharedPreferences.getString(p.getKey(), "");
            setPreferenceSummary(p, value);
        }

    }
}
 
開發者ID:Existentio,項目名稱:OddLauncher,代碼行數:22,代碼來源:SettingsFragment.java

示例5: onCreatePreferences

import android.support.v7.preference.CheckBoxPreference; //導入依賴的package包/類
@Override
public void onCreatePreferences(Bundle bundle, String s) {

    // Add visualizer preferences, defined in the XML file in res->xml->pref_visualizer
    addPreferencesFromResource(R.xml.pref_visualizer);

    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
    PreferenceScreen prefScreen = getPreferenceScreen();
    int count = prefScreen.getPreferenceCount();

    // Go through all of the preferences, and set up their preference summary.
    for (int i = 0; i < count; i++) {
        Preference p = prefScreen.getPreference(i);
        // You don't need to set up preference summaries for checkbox preferences because
        // they are already set up in xml using summaryOff and summary On
        if (!(p instanceof CheckBoxPreference)) {
            String value = sharedPreferences.getString(p.getKey(), "");
            setPreferenceSummary(p, value);
        }
    }
    // COMPLETED (3) Add the OnPreferenceChangeListener specifically to the EditTextPreference
    Preference preference = findPreference(getString(R.string.pref_size_key));
    preference.setOnPreferenceChangeListener(this);
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:25,代碼來源:SettingsFragment.java

示例6: onCreatePreferences

import android.support.v7.preference.CheckBoxPreference; //導入依賴的package包/類
@Override
public void onCreatePreferences(Bundle bundle, String s) {

    // Add visualizer preferences, defined in the XML file in res->xml->pref_visualizer
    addPreferencesFromResource(R.xml.pref_visualizer);

    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
    PreferenceScreen prefScreen = getPreferenceScreen();
    int count = prefScreen.getPreferenceCount();

    // Go through all of the preferences, and set up their preference summary.
    for (int i = 0; i < count; i++) {
        Preference p = prefScreen.getPreference(i);
        // You don't need to set up preference summaries for checkbox preferences because
        // they are already set up in xml using summaryOff and summary On
        if (!(p instanceof CheckBoxPreference)) {
            String value = sharedPreferences.getString(p.getKey(), "");
            setPreferenceSummary(p, value);
        }
    }
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:22,代碼來源:SettingsFragment.java

示例7: onCreatePreferences

import android.support.v7.preference.CheckBoxPreference; //導入依賴的package包/類
@Override
public void onCreatePreferences(Bundle bundle, String s) {

    // Add visualizer preferences, defined in the XML file in res->xml->pref_visualizer
    addPreferencesFromResource(R.xml.pref_visualizer);

    // COMPLETED (3) Get the preference screen, get the number of preferences and iterate through
    // all of the preferences if it is not a checkbox preference, call the setSummary method
    // passing in a preference and the value of the preference
    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    int count = preferenceScreen.getPreferenceCount();

    for (int i = 0; i < count; i++) {
        Preference pref = preferenceScreen.getPreference(i);

        if (!(pref instanceof CheckBoxPreference)) {
            setPreferenceSummary(pref, sharedPreferences.getString(pref.getKey(), ""));
        }
    }
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:22,代碼來源:SettingsFragment.java

示例8: onSharedPreferenceChanged

import android.support.v7.preference.CheckBoxPreference; //導入依賴的package包/類
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Activity activity = getActivity();

    if (key.equals(getString(R.string.pref_location_key))) {
        // we've changed the location
        // Wipe out any potential PlacePicker latlng values so that we can use this text entry.
        SunshinePreferences.resetLocationCoordinates(activity);
    }
    Preference preference = findPreference(key);
    if (null != preference) {
        if (!(preference instanceof CheckBoxPreference)) {
            setPreferenceSummary(preference, sharedPreferences.getString(key, ""));
        }
    }
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:17,代碼來源:SettingsFragment.java

示例9: onSharedPreferenceChanged

import android.support.v7.preference.CheckBoxPreference; //導入依賴的package包/類
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Activity activity = getActivity();

    if (key.equals(getString(R.string.pref_location_key))) {
        // we've changed the location
        // Wipe out any potential PlacePicker latlng values so that we can use this text entry.
        SunshinePreferences.resetLocationCoordinates(activity);
    } else if (key.equals(getString(R.string.pref_units_key))) {
        // units have changed. update lists of weather entries accordingly
        activity.getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    }
    Preference preference = findPreference(key);
    if (null != preference) {
        if (!(preference instanceof CheckBoxPreference)) {
            setPreferenceSummary(preference, sharedPreferences.getString(key, ""));
        }
    }
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:20,代碼來源:SettingsFragment.java

示例10: onSharedPreferenceChanged

import android.support.v7.preference.CheckBoxPreference; //導入依賴的package包/類
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Activity activity = getActivity();

    if (key.equals(getString(R.string.pref_location_key))) {
        // we've changed the location
        // Wipe out any potential PlacePicker latlng values so that we can use this text entry.
        SunshinePreferences.resetLocationCoordinates(activity);
        //  COMPLETED (14) Sync the weather if the location changes
        SunshineSyncUtils.startImmediateSync(activity);
    } else if (key.equals(getString(R.string.pref_units_key))) {
        // units have changed. update lists of weather entries accordingly
        activity.getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    }
    Preference preference = findPreference(key);
    if (null != preference) {
        if (!(preference instanceof CheckBoxPreference)) {
            setPreferenceSummary(preference, sharedPreferences.getString(key, ""));
        }
    }
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:22,代碼來源:SettingsFragment.java


注:本文中的android.support.v7.preference.CheckBoxPreference類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。