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


Java PreferenceCategory類代碼示例

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


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

示例1: addItem

import moe.shizuku.preference.PreferenceCategory; //導入依賴的package包/類
private void addItem (boolean value, Preference.OnPreferenceChangeListener listener
        , CharSequence title, PreferenceCategory parent) {
    SwitchPreferenceCompat preference = new SwitchPreferenceCompat(getActivity(),
            null, moe.shizuku.preference.R.attr.switchPreferenceStyle,
            R.style.Preference_SwitchPreferenceCompat);
    preference.setOnPreferenceChangeListener(listener);
    preference.setTitle(title);
    preference.setChecked(value);
    parent.addPreference(preference);
}
 
開發者ID:Trumeet,項目名稱:MiPushFramework,代碼行數:11,代碼來源:ManagePermissionsActivity.java

示例2: onCreatePreferences

import moe.shizuku.preference.PreferenceCategory; //導入依賴的package包/類
@Override
public void onCreatePreferences(Bundle bundle, String s) {
    getPreferenceManager().setDefaultPackages(new String[]{BuildConfig.APPLICATION_ID + "."});

    getPreferenceManager().setSharedPreferencesName("settings");
    getPreferenceManager().setSharedPreferencesMode(Context.MODE_PRIVATE);

    setPreferencesFromResource(R.xml.settings, null);

    ListPreference listPreference;
    listPreference = (ListPreference) findPreference("drop_down2");
    listPreference.setEntries(new CharSequence[]{"Item 1", "Item 2"});
    listPreference.setEntryValues(new CharSequence[]{Locale.CHINESE.toString(), Locale.ENGLISH.toString()});
    if (listPreference.getValue() == null) {
        listPreference.setValueIndex(1);
    }
    listPreference.setOnPreferenceChangeListener(this);

    listPreference = (ListPreference) findPreference("drop_down3");
    listPreference.setEntries(new CharSequence[]{"Vertical align selected item", "(。>﹏<。)", "(っ╹ ◡ ╹ )っ\uD83D\uDC8A\uFEFF ヽ(✿゚▽゚)ノ", "⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄"});
    listPreference.setEntryValues(new CharSequence[]{"0", "1", "2", "3"});
    if (listPreference.getValue() == null) {
        listPreference.setValueIndex(2);
    }
    listPreference.setOnPreferenceChangeListener(this);

    findPreference("drop_down4").setOnPreferenceChangeListener(this);

    listPreference = (ListPreference) findPreference("drop_down5");
    listPreference.setEntries(new CharSequence[]{"This is a very long item. It will use a simple dialog if its text may wraps to more than one line", "Don't put too many item when use simple dialog", "(<ゝω・)☆"});
    listPreference.setEntryValues(new CharSequence[]{"0", "1", "2"});
    if (listPreference.getValue() == null) {
        listPreference.setValueIndex(2);
    }
    listPreference.setOnPreferenceChangeListener(this);

    PreferenceCategory preferenceCategory = new PreferenceCategory(getContext());
    preferenceCategory.setTitle("Test add dynamically");
    getPreferenceScreen().addPreference(preferenceCategory);

    CheckBoxPreference checkBoxPreference = new CheckBoxPreference(getContext());
    checkBoxPreference.setTitle("Test");
    checkBoxPreference.setSummaryOn("ON");
    checkBoxPreference.setSummaryOff("OFF");
    getPreferenceScreen().addPreference(checkBoxPreference);
}
 
開發者ID:RikkaW,項目名稱:MaterialPreference,代碼行數:47,代碼來源:SettingsFragment.java


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