当前位置: 首页>>代码示例>>Java>>正文


Java PreferenceScreen.getPreference方法代码示例

本文整理汇总了Java中android.support.v7.preference.PreferenceScreen.getPreference方法的典型用法代码示例。如果您正苦于以下问题:Java PreferenceScreen.getPreference方法的具体用法?Java PreferenceScreen.getPreference怎么用?Java PreferenceScreen.getPreference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.preference.PreferenceScreen的用法示例。


在下文中一共展示了PreferenceScreen.getPreference方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreatePreferences

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的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: onCreatePreferences

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的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

示例3: onCreatePreferences

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的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

示例4: onCreatePreferences

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的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);
        }
    }
    // TODO (3) Add the OnPreferenceChangeListener specifically to the EditTextPreference
    Preference preference = findPreference(getString(R.string.pref_size_key));
    preference.setOnPreferenceChangeListener(this);
}
 
开发者ID:soryncrash13,项目名称:Small-Android-apps,代码行数:26,代码来源:SettingsFragment.java

示例5: onCreatePreferences

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的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

示例6: onCreatePreferences

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的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

示例7: onCreatePreferences

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle bundle, String s) {

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

    //set the summaries for the different preferences for the first time
    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
    PreferenceScreen prefScreen = getPreferenceScreen();
    int count = prefScreen.getPreferenceCount();
    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) && !(p instanceof MultiSelectListPreference)) {
            String value = sharedPreferences.getString(p.getKey(), "");
            setPreferenceSummary(p, value);
        }
    }

    //attach listener to check for changes in the radius preference
    //because it should only contain only doubles and the code has to enforce this
    Preference preference = findPreference(getString(R.string.pref_radius_key));
    preference.setOnPreferenceChangeListener(this);
}
 
开发者ID:Jugendhackt,项目名称:Camera-warner,代码行数:26,代码来源:SettingsFragment.java

示例8: onCreatePreferences

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的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:fjoglar,项目名称:android-dev-challenge,代码行数:17,代码来源:SettingsFragment.java

示例9: onCreatePreferences

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle bundle, String s) {
    /* Add 'general' preferences, defined in the XML file */
    addPreferencesFromResource(R.xml.pref_general);

    // COMPLETED (9) Set the preference summary on each preference that isn't a CheckBoxPreference
    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:sagarchoudhary96,项目名称:Project-Sunshine,代码行数:18,代码来源:SettingsFragment.java

示例10: getEnabledMimics

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
private ArrayList<String> getEnabledMimics() {
    ArrayList<String> enabledMimics = new ArrayList<>();
    PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
    for (int i = 0; i < preferenceScreen.getPreferenceCount(); i++) {
        CheckBoxPreference preference = (CheckBoxPreference)preferenceScreen.getPreference(i);
        if (preference.isChecked()) {
            enabledMimics.add(preference.getKey());
        }
    }
    return enabledMimics;
}
 
开发者ID:Microsoft,项目名称:ProjectOxford-Apps-MimickerAlarm,代码行数:12,代码来源:MimicsSettingsFragment.java

示例11: getOnScreenPrefs

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
private Preference[] getOnScreenPrefs() {
    PreferenceScreen prefScreen = getPreferenceScreen();
    Preference[] prefs = new Preference[prefScreen.getPreferenceCount()];
    for (int i = 0; i < prefScreen.getPreferenceCount(); i++) {
        prefs[i] = prefScreen.getPreference(i);
    }
    return prefs;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:9,代码来源:DeveloperPreferences.java


注:本文中的android.support.v7.preference.PreferenceScreen.getPreference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。