listpreference

How to make a Preference not save to SharedPreferences?

别等时光非礼了梦想. 提交于 2019-12-11 06:48:56
问题 I am re-using ListPreference for a setting which I store only in the database. How can I prevent it from storing/persisting any data to the preference file? 回答1: Subclass it, override shouldPersist() to return false. 回答2: I've not done it myself, but have you looked into overriding onDialogClosed() ? 来源: https://stackoverflow.com/questions/2488830/how-to-make-a-preference-not-save-to-sharedpreferences

How to create a Listener to Preferences changes in Preferences activity?

冷暖自知 提交于 2019-12-11 04:44:45
问题 I have Preferences activity in my app that has ListPreference so the user can choose language for the app. The app displays the new language just after the user close the Preferences activity. I want to create a listener to the ListPreference so the app will restart when the Listener is triggers (just after the user choose a language/choose item from the ListPreference). How can I do that? SettingsActivity: public class SettingsActivity extends AppCompatPreferenceActivity { /** * A preference

How can I change the appearance of ListPreference Dialog

雨燕双飞 提交于 2019-12-10 17:36:16
问题 I would like to change the RadioButton that appears on ListPreference dialog for a check mark or something different, or none, is there a simple way to do this? 回答1: If you want to change the whole dialog, maybe to use a replacement dialog library like this material-dialogs package, you can use this replacement ListPreference : import com.afollestad.materialdialogs.MaterialDialog; public class MaterialListPreference extends ListPreference { private MaterialDialog.Builder mBuilder; private

Error java.lang.NullPointerException on method getReadableDatabase()

泄露秘密 提交于 2019-12-08 11:56:02
问题 Could you please help me with error "java.lang.NullPointerException". I use custom listpreference to show elements from database. There two files CustomListPreference.java and DbHelper.java CustomListPreference.java public class CustomListPreference extends ListPreference { CustomListPreferenceAdapter customListPreferenceAdapter = null; Context mContext; private SQLiteDatabase db; DbHelper dbHelp = new DbHelper(mContext); public CustomListPreference(Context context, AttributeSet attrs) {

Android: How to remove arrow down icon next to EditTextPreference entry?

蓝咒 提交于 2019-12-08 07:04:57
问题 The preference activity gets inflated by invoking addPreferencesFromResource(R.xml.preferences); and here are the preferences.xml: <PreferenceCategory android:title="@string/pref_categ_update_label"> <ListPreference android:title="@string/pref_label" android:key="update_interval" android:entries="@array/update_names" android:entryValues="@array/update_values" /> </PreferenceCategory> <PreferenceCategory android:title="@string/pref_categ_evernote_label"> <EditTextPreference android:title="

Android: How to remove arrow down icon next to EditTextPreference entry?

放肆的年华 提交于 2019-12-07 07:16:28
The preference activity gets inflated by invoking addPreferencesFromResource(R.xml.preferences); and here are the preferences.xml: <PreferenceCategory android:title="@string/pref_categ_update_label"> <ListPreference android:title="@string/pref_label" android:key="update_interval" android:entries="@array/update_names" android:entryValues="@array/update_values" /> </PreferenceCategory> <PreferenceCategory android:title="@string/pref_categ_evernote_label"> <EditTextPreference android:title="@string/pref_dialog_edit_username" android:key="prefUsername" android:positiveButtonText="@string/save_pref

How do you change the textcolor of the list items in an AlertDialog

牧云@^-^@ 提交于 2019-12-07 03:35:38
问题 Hello I am trying to change the text color of the items in a list on a ListPreference pop up window. I have spent over an hour looking through all of the various style names but I can't find TextAppearance or anything that goes to this particular text. Thanks for your help! 回答1: You can't and you shouldn't. *Preference uses styles from com.android.internal.R.styleable which might be changed by manufactures. The idea of using the default ones is that every preference screen in your device look

How do you change the textcolor of the list items in an AlertDialog

扶醉桌前 提交于 2019-12-05 07:20:18
Hello I am trying to change the text color of the items in a list on a ListPreference pop up window. I have spent over an hour looking through all of the various style names but I can't find TextAppearance or anything that goes to this particular text. Thanks for your help! You can't and you shouldn't. *Preference uses styles from com.android.internal.R.styleable which might be changed by manufactures. The idea of using the default ones is that every preference screen in your device look alike. On the other hand you can try doing an Activity with android:theme="@android:style/Theme.Dialog" in

OnSharedPreferenceChangeListener not registering change in preference

时光总嘲笑我的痴心妄想 提交于 2019-12-04 22:43:13
I'm working on listpreferences and I have implemented the OnSharedPreferenceChangeListener to change the text on a textview based on which item is selected on the listpreference. However it doesn't register any changes and I have run out of ideas so any help would be appreciated. Thanks public class pref extends PreferenceActivity implements OnSharedPreferenceChangeListener { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.prefs); setContentView(R.layout.main);

SharedPreference Changes not reflected in my wallpaper service

家住魔仙堡 提交于 2019-12-04 07:37:02
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"); currValue = listPreference.getValue(); Log.e("LiveWallpaperSettings", "currvalue " + currValue);