listpreference

ListPreference summary not formatting

一世执手 提交于 2019-12-23 05:29:09
问题 I have a ListPreference and I want to show the current entry in the summary. According to the docs for ListPreference.getSummary(), I'm supposed to be able to do this by including %s in the summary string. Unfortunately, the activity just displays the %s in the summary. The XML is pretty standard: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <ListPreference android:key="displayMode" android:summary="@string/display_mode

Why does ListView stays above TextView in ListPreference dialog?

让人想犯罪 __ 提交于 2019-12-21 12:09:13
问题 I need to create a custom ListPreference dialog so that I can add some header text (a TextView) above the List (ListView). I've created MyListPreference class that extends ListPreference and overrides onCreateDialogView(): @Override protected View onCreateDialogView() { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = (View) inflater.inflate(R.layout.dialog_preference_list, null); return v; } My XML layout dialog_preference

custom row in a listPreference?

六月ゝ 毕业季﹏ 提交于 2019-12-17 03:31:05
问题 I am trying to create a ListPreference but somehow disable one of the items. Sort of like gray it out or something and not have the ability to choose it. It will be an upcoming feature and I want it to be in the list just not selectable. I have created a custom ListPreference class and in that class a custom adapter, hoping to use the adapter to create what I want. The code works, and it sets the adapter, but none of the adapter functions get called. I set breakpoints on the methods, such as

Update ListPreference summary on language change

折月煮酒 提交于 2019-12-13 07:31:54
问题 When a new language is selected in my ListPreference , I change it and reload my Fragment in order to apply it, like such: listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { // Get selected language String selectedLanguage = newValue.toString(); preference.setSummary(selectedLanguage); // Change language Locale locale; if (selectedLanguage.equals("French")) { locale =

SharedPreference Changes not reflected in my wallpaper service

我与影子孤独终老i 提交于 2019-12-12 08:54:43
问题 I am making a live wallpaper where i need to change the speed of a vehicle in setting scene and it needs to get reflected back to the wallpaper service when i press the return button. In my preference activity, i save the list preference changes in shared preferences like this :- @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.prefs); ListPreference listPreference = (ListPreference) findPreference("listPref");

Android is Crashing on ListPreference

冷暖自知 提交于 2019-12-12 04:43:30
问题 I am trying to get the value after the it is selected in setting preferences dialog. But I get a ClassCastException and a crash? Probably because I'm not sure how to get the value that has been selected and save it. Essentially I need to be able to get the new value in another Activity . How do you get these values and save and be able to find them in other activities? public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { SharedPreferences s =

Android adding item to list preference programaticly

核能气质少年 提交于 2019-12-11 18:34:26
问题 I feel like i have been searching every where without finding an answer to this. I have a list preference <ListPreference android:key="signedUpCompetetion" android:entries="@array/listArray" android:entryValues="@array/listValues" /> With the following entries and entryValues: <resources> <string-array name="listArray"> <item></item> <item></item> <item></item> </string-array> <string-array name="listValues"> <item></item> <item></item> <item></item> </string-array> </resources> So say that

ListPreference font size

和自甴很熟 提交于 2019-12-11 10:28:43
问题 I'm using ListPreference to have the user select a location from a list. Some of the entries are cut off bcs of too long strings. I'm looking for the simplest possible way to work around this. One variant would be to just use a smaller font size. In case it's not too much overhead, I would additionally split the text shown into 2 strings on different lines. 回答1: Extend ListPreference and override onCreateView() like this: @Override protected View onCreateView(ViewGroup parent) { View view =

Show a Toast when user change setting in preferences activity

*爱你&永不变心* 提交于 2019-12-11 08:17:13
问题 I have a preferences Activity with a ListPreference on it and I use this preferences in another activity, But I want to show a Toast whenever, user changing option in preference Activity. For example, when user clicks on second radio button in ListPreference, suddenly a toast shown and says "second". 回答1: What is the problem? Resolve the preference and set a listener that does the toast? Something like this for example ListPreference listPreference = findPreference(key); listPreference

Change font typeface of summary of `ListPreference`

删除回忆录丶 提交于 2019-12-11 08:04:15
问题 I tried with THIS LINK to change the typeface of all preferences of PreferenceScreen . It was changed everywhere except summary of ListPreference . Can anyone has an idea how to apply custom font on summary of ListPreference ? UPDATE I want to apply my custom font exist on assets folder, not the in-build one. Also android:textAppearanceListItemSecondary required API 21, my app support minimum API 15. 回答1: try this <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat