本文整理匯總了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);
}
示例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);
}