listpreference

Custom layout ListPreference

旧时模样 提交于 2019-12-01 07:34:04
问题 Prompt please where it is possible to read about creating a custom layout listpreference ( background and layout top panel, panel button ). Met - examples only for custom row. Sorry - google translate. 回答1: in your preference.xml file you can refer to your custom ListPreference by the full name of the class i.e. com.example.MyPreference <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:key="pref_wifi_key" android:title=

How to edit/reset Alarm Manager?

故事扮演 提交于 2019-11-30 21:14:50
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:positiveButtonText="OK" android:negativeButtonText="Cancel" android:entries="@array/entries" android

ListPreference: use string-array as Entry and integer-array as Entry Values doesn't work

旧城冷巷雨未停 提交于 2019-11-30 06:28:30
问题 I'm using in a settings.xml file a ListPreference. I want to show the user a list of 3 options to select. When the user chooses one of the options in the Settings, I get this error: java.lang.NullPointerException at android.preference.ListPreference.onDialogClosed(ListPreference.java:264) at android.preference.DialogPreference.onDismiss(DialogPreference.java:381) at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1228) at android.os.Handler.dispatchMessage(Handler.java:99) at

Using list preference in Android

天大地大妈咪最大 提交于 2019-11-28 21:01:00
问题 I have a text to speech application where the user can select a language and also select a male or female voice. The problem is that for each language there are different strings used to called the male and female voice but in my preference I only have two options (male and female). <string-array name="Language"> <item>English (US)</item> <item>English (UK)</item> <item>French (France)</item> <item>Spanish (Spain)</item> <item>Italian</item> </string-array> <string-array name="languageAlias">

ListPreference: use string-array as Entry and integer-array as Entry Values doesn't work

假如想象 提交于 2019-11-28 19:03:31
I'm using in a settings.xml file a ListPreference. I want to show the user a list of 3 options to select. When the user chooses one of the options in the Settings, I get this error: java.lang.NullPointerException at android.preference.ListPreference.onDialogClosed(ListPreference.java:264) at android.preference.DialogPreference.onDismiss(DialogPreference.java:381) at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1228) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4424) at

How to Get Selected Text and Value Android ListPreference

若如初见. 提交于 2019-11-28 09:45:33
The XML file of my ListPreference <ListPreference android:key="lpBirim" android:title="Birim" android:summary="" android:defaultValue="0" android:persistent="false"/> How to get the selected text and the selected value? in your PreferenceActivity do something like: ListPreference listPreference = (ListPreference) findPreference("lpBirim"); CharSequence currText = listPreference.getEntry(); String currValue = listPreference.getValue(); Sunil Kumar Sahoo You can use this snippet to get the value: SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); sp.getString("lpBirim","

How to set the Default Value of a ListPreference

£可爱£侵袭症+ 提交于 2019-11-28 09:35:05
i need to set the defult value for a ListPreference when the Activity starts. I've tried with ListPreference.setDefaultvalue("value"); but it makes the firts Entry of the List as default. I need it because i must check a condition and set as default the value which satisfies that condition, so I think it can't be done from the xml file (with android:defaultValue ) For example, suppose I have this array of values in the arrays.xml: <string-array name="opts"> <item>red</item> <item>green</item> <item>blue</item> </string-array> <string-array name="opts_values"> <item>1</item> <item>2</item>

How to set the Default Value of a ListPreference

被刻印的时光 ゝ 提交于 2019-11-27 04:33:15
问题 i need to set the defult value for a ListPreference when the Activity starts. I've tried with ListPreference.setDefaultvalue("value"); but it makes the firts Entry of the List as default. I need it because i must check a condition and set as default the value which satisfies that condition, so I think it can't be done from the xml file (with android:defaultValue ) For example, suppose I have this array of values in the arrays.xml: <string-array name="opts"> <item>red</item> <item>green</item>

How to Get Selected Text and Value Android ListPreference

爷,独闯天下 提交于 2019-11-27 03:11:15
问题 The XML file of my ListPreference <ListPreference android:key="lpBirim" android:title="Birim" android:summary="" android:defaultValue="0" android:persistent="false"/> How to get the selected text and the selected value? 回答1: in your PreferenceActivity do something like: ListPreference listPreference = (ListPreference) findPreference("lpBirim"); CharSequence currText = listPreference.getEntry(); String currValue = listPreference.getValue(); 回答2: You can use this snippet to get the value:

How to customize list preference radio button

一笑奈何 提交于 2019-11-27 00:52:12
I have customized all the radioButtons in my application but the radioButtons in the listPreference does not get customized. I have used this xml named btn_radio.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:state_window_focused="false" android:drawable="@drawable/radio_selected" /> <item android:state_checked="false" android:state_window_focused="false" android:drawable="@drawable/radio_unselected" /> <item android:state_checked="true" android:state_pressed="true" android:drawable="