android-preferences

Layout for TimePicker-based DialogPreference

杀马特。学长 韩版系。学妹 提交于 2019-12-06 17:01:02
问题 I'm writing an app that requires a TimePicker-based preference (two, actually) and I swiped some (Apache-licensed) code from the Android Programming Tutorials book. I've modified it to work a little better, but there's one thing puzzling me. I haven't tried it on an actual device yet but on emulators it now takes into account system settings for 24-hour time display, clears focus on the TimePicker dialog so that the time is read even when edited manually instead of using the arrow keys, and -

Adding listeners to individual ListPreference items

寵の児 提交于 2019-12-06 13:48:24
I'm trying to add individual listeners to items in a ListPreference but I just can't find the right code to do it. For example, assume I have an app where needs the region to be set. So I have a ListPreference with three options; Americas, Asia, Europe. When I use the trackpad to scroll through the items I would like them to speak the text of the preference when they get focus. I'm sure somewhere in the API I can add a listener to the individual items but I just can not find it. There is a setOnPreferenceClickListener(..) method in ListPreference (inherited from DialogPreference ) but that is

Change the background color of PreferenceFragment

☆樱花仙子☆ 提交于 2019-12-06 11:11:01
问题 I'm using PreferenceFragment with its xml file as following public class ReaderPreferences extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preference); } } preference.xml: <PreferenceCategory android:key="general" android:title="General" > <CheckBoxPreference android:defaultValue="true" android:key="notify_me" android:summary="Notify me about quote of the day in notifications" android

Change Activity Theme From a Fragment

主宰稳场 提交于 2019-12-06 09:33:47
I have a settings PreferenceFragment that allows the user to select a theme. The user can select a dark or light theme. After selecting a theme the user presses the back button to return to the previous fragment. This called the containing activity's onCreate method where the theme is read and applied. However the theme is not applied correctly, Switching from Holo.Light to Holo.Dark changes the background colour, action bar etc but does not change the text resulting in faded, hard to read text. Any ideas what I am doing wrong? Everything I have read says that the theme should be applied in

Rotating Android device while viewing dialog preference with TimePicker or NumberPicker causes app crash

前提是你 提交于 2019-12-06 09:09:29
问题 I've made a custom DialogPreference which uses two NumberPicker widgets on it to allow a user to select an hour of the day as well as another custom DialogPreference which allows a user to select a time of day using a TimePicker widget. As long as the dialog is not open and I rotate the screen, everything works as desired. However, if the dialog is open and the screen is rotated then the entire app crashes. I've placed break points in the onSaveInstanceState and onRestoreInstanceState methods

Can't set header preference icon via ?attr

落爺英雄遲暮 提交于 2019-12-06 05:51:36
问题 I have created preference-headers.xml. I want to set header icon via ?attr , but it doesn't show the icon. <?xml version="1.0" encoding="utf-8"?> <preference-headers xmlns:android="http://schemas.android.com/apk/res/android" > <header android:fragment="com.armsoft.mtrade.activities.PreferencesActivity$PrefsAboutFragment" android:icon="?attr/menuIconAbout" android:title="@string/about" /> </preference-headers> 回答1: I solved the problem with a mixture of headers.xml and Changing the icon.

Android PreferenceFragment No view found for id for fragment

ぐ巨炮叔叔 提交于 2019-12-06 01:59:43
So I'm making an android application and I started dealing with preferences, when I simply use a PreferenceActivity, everything works perfectly, however, if I use it with a PreferenceFragment, it crashes right after I click the button that calls intents to SettingsActivity with an error: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{*app package*/*app package*.SettingsActivity}: java.lang.IllegalArgumentException: No view found for id 0x7f08003d for fragment SettingsFragment{41cc1a98 #0 id=0x7f08003d} this is SettingsActivity: public class

preferencefragment no view found for id android

霸气de小男生 提交于 2019-12-05 21:54:29
问题 I had the getpreferencescreen deprecated so I tryed to implement the header preference activity. here is my code: public class EditPreferences extends PreferenceActivity { ListPreference m_list_preference_dive_centre_rating; ListPreference m_list_preference_dive_region_rating; ListPreference m_list_preference_wreck; ListPreference m_list_preference_cave; MultyChoiceListPlugin m_list_preference_marine_life; ListPreference m_list_preference_region; Preference m_order_by_name; SharedPreferences

changing the preference category label color background

故事扮演 提交于 2019-12-05 21:21:40
I would like to change the color of the preference category bakcgorund. In my xml with preferences I have categories typed in this way: <PreferenceCategory android:title="Synchronization"> ... </PreferenceCategory> I am trying to change the background using xml attribute: android:widgetLayout="@style/PreferenceCategory" And the code in my styles.xml looks like: <resources> <style name="PreferenceCategory"> <item name="android:background">@color/my_blue</item> </style> </resources> But it isn't work properly. I have fatal exception: 08-13 01:43:09.111: WARN/dalvikvm(1329): threadid=1: thread

save value of spinner selected item using shared preference

拥有回忆 提交于 2019-12-05 16:19:15
How can I save the current selected spinner value, such that when I reopen the application the saved value is automatically selected by default? My current code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.loginpage); final Spinner spinner = (Spinner) findViewById(R.id.spinner1); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( this, R.array.spinner_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);