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


Java PreferenceScreen.findPreference方法代码示例

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


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

示例1: onCreatePreferences

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

    // Get our screen which is created in Skin SettingsFragment
    PreferenceScreen screen = getPreferenceScreen();

    // Get profile preference
    PreferenceCategory category = (PreferenceCategory) screen.findPreference(KEY_PROFILE);

    // If category exists, we should add mole mapper specific things. If not, that means we
    // are not consented so we have no data to set.
    if(category != null)
    {
        // Example Preference
        Preference checkBoxPref = new Preference(screen.getContext());
        checkBoxPref.setKey(KEY_EXAMPLE);
        checkBoxPref.setTitle("Example Title");
        checkBoxPref.setSummary("You need to extend your settings fragment from Skin's " +
                "Settings fragment and then modify any preferences that you'd like");
        category.addPreference(checkBoxPref);
    }
}
 
开发者ID:daviszhou,项目名称:BeaconTrackerAndroid,代码行数:25,代码来源:SampleSettingsFragment.java

示例2: onPreferenceChange

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    PreferenceScreen ps = getPreferenceScreen();
    Boolean newChecked = (Boolean)newValue;

    if (newChecked.booleanValue() == false) {
        int checkedCount = 0;

        for (String k : POI_KEYS) {
            if (preference.getKey().equals(k)) continue;
            CheckBoxPreference cbp = (CheckBoxPreference)ps.findPreference(k);
            if (cbp.isChecked()) {
                checkedCount++;
            }
        }

        if (checkedCount == 0) {
            Toast.makeText(getActivity(), R.string.prompt_at_least_one_poi, Toast.LENGTH_SHORT).show();
            return false;
        }
    }

    return true;
}
 
开发者ID:OsmHackTW,项目名称:Geomancer,代码行数:25,代码来源:SettingsFragment.java

示例3: onCreatePreferences

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

    // Get our screen which is created in Skin SettingsFragment
    PreferenceScreen screen = getPreferenceScreen();
    screen.getSharedPreferences().registerOnSharedPreferenceChangeListener(this);

    profileCategory = (PreferenceCategory) screen.findPreference(KEY_PROFILE);

    privacyCategory = (PreferenceCategory) screen.findPreference(KEY_PRIVACY);
    sharingScope = privacyCategory.findPreference(KEY_SHARING_OPTIONS);

    generalCategory = (PreferenceCategory) screen.findPreference(KEY_GENERAL);
    leaveStudy = generalCategory.findPreference(KEY_LEAVE_STUDY);
    joinStudy = generalCategory.findPreference(KEY_JOIN_STUDY);

    // Set version string
    screen.findPreference(KEY_VERSION).setSummary(getVersionString());
}
 
开发者ID:ResearchStack,项目名称:ResearchStack,代码行数:21,代码来源:SettingsFragment.java

示例4: setupLibrariesPreference

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
/**
 * Adds libraries to its PreferenceCategory programmatically.
 */
private void setupLibrariesPreference(PreferenceScreen preferenceScreen) {
    PreferenceCategory preferenceCategory = (PreferenceCategory)
            preferenceScreen.findPreference(getString(R.string.pref_key_libraries));
    Context context = preferenceCategory.getContext();
    for (@Size(2) String[] libraryInfos : getLibrariesInfos()) {
        Preference preference = new Preference(context);
        preference.setTitle(libraryInfos[0]);
        preference.setPersistent(false);
        // put this library's license path to extra
        preference.getExtras().putString(EXTRAS_LIBRARY_OR_FILE_OPEN_SOURCE_LICENSE_FILE_PATH,
                ASSET_PATH_OPEN_SOURCE_LICENSES_LIBRARY + libraryInfos[1]);
        preferenceCategory.addPreference(preference);
    }
}
 
开发者ID:ykrank,项目名称:S1-Next,代码行数:18,代码来源:OpenSourceLicensesFragment.java

示例5: setupFilesPreference

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
/**
 * Adds files to its PreferenceCategory programmatically.
 */
private void setupFilesPreference(PreferenceScreen preferenceScreen) {
    PreferenceCategory preferenceCategory = (PreferenceCategory)
            preferenceScreen.findPreference(getString(R.string.pref_key_files));
    Context context = preferenceCategory.getContext();
    for (@Size(2) String[] fileInfos : getFilesInfo()) {
        Preference preference = new Preference(context);
        preference.setTitle(fileInfos[0]);
        preference.setPersistent(false);
        // put this file's license path to extra
        preference.getExtras().putString(EXTRAS_LIBRARY_OR_FILE_OPEN_SOURCE_LICENSE_FILE_PATH,
                ASSET_PATH_OPEN_SOURCE_LICENSES_FILE + fileInfos[1]);
        preferenceCategory.addPreference(preference);
    }
}
 
开发者ID:ykrank,项目名称:S1-Next,代码行数:18,代码来源:OpenSourceLicensesFragment.java

示例6: updateContent

import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
private void updateContent() {
    PreferenceScreen root = getPreferenceScreen();

    if (McsService.isConnected()) {
        root.findPreference(PREF_GCM_STATUS).setSummary(getString(R.string.gcm_state_connected, DateUtils.getRelativeTimeSpanString(McsService.getStartTimestamp(), System.currentTimeMillis(), 0)));
    } else {
        root.findPreference(PREF_GCM_STATUS).setSummary(getString(R.string.gcm_state_disconnected));
    }

    PreferenceCategory appList = (PreferenceCategory) root.findPreference(PREF_GCM_APPS);
    appList.removeAll();
    List<GcmDatabase.App> list = database.getAppList();
    if (!list.isEmpty()) {
        List<Preference> appListPrefs = new ArrayList<>();
        PackageManager pm = getContext().getPackageManager();
        for (GcmDatabase.App app : list) {
            try {
                pm.getApplicationInfo(app.packageName, 0);
                appListPrefs.add(new GcmAppPreference(getPreferenceManager().getContext(), app));
            } catch (PackageManager.NameNotFoundException e) {
                final List<GcmDatabase.Registration> registrations = database.getRegistrationsByApp(app.packageName);
                if (registrations.isEmpty()) {
                    database.removeApp(app.packageName);
                } else {
                    appListPrefs.add(new GcmAppPreference(getPreferenceManager().getContext(), app));
                }
            }
        }
        addPreferencesSorted(appListPrefs, appList);
    } else {
        // If there's no item to display, add a "None" item.
        Preference banner = new Preference(getPreferenceManager().getContext());
        banner.setLayoutResource(R.layout.list_no_item);
        banner.setTitle(R.string.list_no_item_none);
        banner.setSelectable(false);
        appList.addPreference(banner);
    }
}
 
开发者ID:microg,项目名称:android_packages_apps_GmsCore,代码行数:39,代码来源:GcmFragment.java

示例7: onCreatePreferences

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

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(
            getContext());

    // Get our screen which is created in Skin SettingsFragment
    PreferenceScreen screen = getPreferenceScreen();

    // Get profile preference
    PreferenceCategory category = (PreferenceCategory) screen.findPreference(KEY_PROFILE);

    // If category exists, we should add mole mapper specific things. If not, that means we
    // are not consented so we have no data to set.
    if(category != null)
    {
        // Occupation Preference
        Preference checkBoxPref = new Preference(screen.getContext());
        checkBoxPref.setKey(KEY_PROFILE_PROFESSION);
        checkBoxPref.setTitle(R.string.profession);
        checkBoxPref.setSummary(R.string.profession_unknown); // Set to prevent a "jump" when first entering the screen
        category.addPreference(checkBoxPref);
    }

    // Create the app category to place out two rpefs
    PreferenceCategory appCategory = new PreferenceCategory(screen.getContext());
    appCategory.setKey(KEY_APP);
    appCategory.setTitle(R.string.settings_app);
    appCategory.setOrder(1);
    screen.addPreference(appCategory);

    // Generate values for the mole naming convention pref
    MoleNameHelper.Gender[] values = MoleNameHelper.Gender.values();
    String[] entries = new String[values.length];
    String[] entryValues = new String[values.length];
    for(int i = 0; i < values.length; i++)
    {
        MoleNameHelper.Gender gender = values[i];
        entries[i] = getString(gender.getNameResourceId());
        entryValues[i] = Integer.toString(i);
    }

    // Create ListPreference and add to "App" category
    String defaultNamingConvention = Integer.toString(MoleNameHelper.Gender.RANDOM.ordinal());
    ListPreference namingConventionPref = new ListPreference(screen.getContext());
    namingConventionPref.setTitle(R.string.settings_app_mole_name_scheme);
    namingConventionPref.setKey(KEY_APP_MOLE_NAMING);
    namingConventionPref.setDefaultValue(defaultNamingConvention);
    namingConventionPref.setEntries(entries);
    namingConventionPref.setEntryValues(entryValues);
    namingConventionPref.setDialogTitle(R.string.settings_app_mole_name_scheme);
    String currentNamingConvInt = sharedPreferences.getString(KEY_APP_MOLE_NAMING,
            defaultNamingConvention);
    int currentNamingOrdinal = Integer.parseInt(currentNamingConvInt);
    namingConventionPref.setSummary(values[currentNamingOrdinal].getNameResourceId());
    appCategory.addPreference(namingConventionPref);
}
 
开发者ID:ResearchStack,项目名称:MoleMapperAndroid,代码行数:60,代码来源:MoleMapperSettingsFragment.java


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