listpreference

How to add ripple effect to preferences in android?

蓝咒 提交于 2021-02-07 11:58:42
问题 I am working on adding ripple effect when the preference is touched (selected). I have customized my preference by extending the ListPreference . I have tried to set the ripple effect programmatically by using RippleDrawable but I don't see the animation. Here is my customized preference class public class CustomListPreference extends ListPreference { public CustomListPreference(Context context, AttributeSet attrs) { super(context, attrs); } public CustomListPreference(Context context) {

Loading JSON data to android listpreference

和自甴很熟 提交于 2020-01-23 12:36:05
问题 I have a problem.I have read many forums and topics but I can not understand how to create a class file to load JSON data like: {"city":[{"id":"1","name":"London"},{"id":"2","name":"Berlin"},{"id":"3","name":"New York"}],"success":1} to an ListPreference list for saving one value to shared preference file. Like my saved url: <string name="URL">192.168.1.100/data</string> without deprecated methods ( findPreference("city") ). The preference xml which I use is <?xml version="1.0" encoding="utf

Reading from file and add to list preference

久未见 提交于 2020-01-15 12:32:47
问题 I have the following code: PreferenceScreen root = this.getPreferenceScreen(); ListPreference lp = (ListPreference) root.findPreference("signedUpCompetetion"); CharSequence[] entries = null; CharSequence[] entryValues = null; FileInputStream fis; try { fis = openFileInput("list_file.txt"); InputStreamReader inputStreamReader = new InputStreamReader(fis); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); String line; entries = new CharSequence[10]; entryValues = new

Reading from file and add to list preference

风格不统一 提交于 2020-01-15 12:32:21
问题 I have the following code: PreferenceScreen root = this.getPreferenceScreen(); ListPreference lp = (ListPreference) root.findPreference("signedUpCompetetion"); CharSequence[] entries = null; CharSequence[] entryValues = null; FileInputStream fis; try { fis = openFileInput("list_file.txt"); InputStreamReader inputStreamReader = new InputStreamReader(fis); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); String line; entries = new CharSequence[10]; entryValues = new

findpreference undefined type

廉价感情. 提交于 2020-01-06 19:43:49
问题 I am trying to set a value to a ListPreference and always get the error message: The method findPreference(String) is undefined for the type new DialogInterface.OnClickListener(){} This is my code: ListPreference lp = (ListPreference) findPreference("enableTranslations"); lp.setValue(""); Thanks 回答1: You simply call findPreference in wrong place (in OnClickListener). Call it in method of class that has findPreference method (PreferenceManager or PreferenceActivity) or on object of such type.

How to add new value to listpreference and save it?

天大地大妈咪最大 提交于 2020-01-06 19:28:37
问题 I have a list Preference that created from resource xml. I added preference that created dialog in which user can add value to listPreference. using those methods i added new value: entries = getEntries(); entryValues = getEntryValues(); when user is adding values to listpreference, its displayed. But when preferenceScreen is recreating new value disappearing. How can i save those new values? 回答1: Problem is that when you're reopening your PreferenceScreen , it loads the ListPreference 's

OnSharedPreferenceChangeListener not registering change in preference

∥☆過路亽.° 提交于 2020-01-01 19:56:28
问题 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

How to set icon in ListPreference's item in android

丶灬走出姿态 提交于 2019-12-30 07:49:16
问题 I want to set the icon in ListPreference items in android. What to write in ListPreference or where to write to set the list items icon? 回答1: You need to use a custom layout for your ListPreference . eg: <android.preference.ListPreference android:layout="@layout/your_custom_layout" .... /> And add what you want to your custom layout. eg: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android

How to edit/reset Alarm Manager?

邮差的信 提交于 2019-12-30 06:46:33
问题 I've set up a Preference Screen in which i have a list preference which allows user to select time interval to notify them. They can choose whether to notify them after every 2,4,8,10 or 12 hours. Here's my list preference: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <ListPreference android:title="Notification Timer" android:summary="Select when to Notify" android:dialogTitle="Show Notification after every:" android

Android listpreference - fetching value

不问归期 提交于 2019-12-24 03:30:57
问题 I have a listpreference . No matter how I copy the code here, it appears wrong, so I just copy the matter of it: string-array name="listArray" items: Mercedes, Audi, Porsche string-array name="listValues" items: car1, car2, car3 I have this code in the preferences.xml at the listpreference part: <ListPreference android:title="List Preference" android:summary="This preference allows to select an item in a array" android:key="listPref" android:defaultValue="digiGreen" android:entries="@array