android-preferences

Separate preferences for each view in an Android app

依然范特西╮ 提交于 2020-01-02 05:32:05
问题 I have multiple views that come and go as the application runs. I want each view to have its own personal preferences that are stored as the ID tag of the view. Above these is the "General Preferences" that the sub prefs reference to get their default values when a view it is created. Right now I have it set up that the General Preferences are the default SharedPreferences. But I have no Idea how to create the new preferences and set up an activity UI so the user can change them. Is it pretty

Add a button in Preference Row

最后都变了- 提交于 2020-01-02 04:25:09
问题 I want a button in my Settings screen. This exact question has been asked here. But unfortunately has no answers. :( In order to get to this, I created a custom preference like this - public class CustomPreference extends Preference { private LinearLayout mWidgetContainer; private View mRowView; public CustomPreference(Context context) { super(context); } public CustomPreference(Context context, AttributeSet attrs) { super(context, attrs); } public CustomPreference(Context context,

Can't get settings button to display for live wallpaper

怎甘沉沦 提交于 2020-01-01 14:57:40
问题 I want to add settings to a live wallpaper I created. I am missing something very fundamental about how SharedPreferences work. The code and XML are based on the cube live wallpaper example and I can’t figure out what I did wrong. My problem is that no "Settings" button shows up when I choose my live wallpaper from the list. Only the "Set Wallpaper" button is displayed. I suspect that I screwed up something in the XML. This is a very simple live wallpaper I made just to fool around with

Default bindPreferenceSummaryToValue crashes for non-string types

随声附和 提交于 2020-01-01 04:37:13
问题 I'm following the example method to add a compatible preference/ fragment dialog found here. When doing so, I have found that if I have preferences that are Integers, Boolean, etc, it just crashes. private static void bindPreferenceSummaryToValue(Preference preference) { // Set the listener to watch for value changes. preference .setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value.

Get view of preference with custom layout

依然范特西╮ 提交于 2020-01-01 04:30:07
问题 I have a preference android:layout gft. I've set the layout in the android:layout property of the preference in the xml file. Now I need to do an initialization of a button in the layout (it's a +1 button). I need to get that button in the onCreate method (it's a +1 button) but when I use findViewById(button_id) , it returns null. Is there some way to get the view of this preference? UPDATE: It seems like the preference isn't created after I add the preference xml, so I get null. Where I can

Start Activity from preferences.xml and get the result in onActivityResult

拜拜、爱过 提交于 2020-01-01 04:04:08
问题 It's a complement to this question. I can launch the Activity but I also need to be able to get the result. How do I do it? I tried overriding onActivityResult on my PreferencesActivity to no avail. Am I missing some extra properties in the preferences.xml? 回答1: The cleanest solution that I know of is to listen to the click on the preference and launch the intent explicitly. This way onActivityResult will be called as usual. Assuming that your intent-preference is defined in XML you can

Android Preference Fragment Text Color

十年热恋 提交于 2019-12-31 09:29:06
问题 I want to change the text color in android preferences fragment. I am currently using a custom theme to change the checkbox image, background, onClick highlighting and it all works great...besides the text color. I don't want to use a default theme, I want to have my own theme so it all looks how I want to but just change the text color, can someone please help. styles.xml <?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name

Changing language in run time with Preferences [android]

穿精又带淫゛_ 提交于 2019-12-30 13:55:33
问题 I read a few times the official guide for this, and many other stuff, like questions on this site but I cant make mine work 100% As of right now if I change the language in my list preference, the activity (SettingsActivity) will not update itself (like 1 out of 20 times, somehow it will, no idea why). After I press the back button, my MainActivity did not update either. But all my other activitys always show the correct language, and if I go back to the SettingsActivity it will be okay, same

Extending Preference classes in Android Lollipop = losing animation

人盡茶涼 提交于 2019-12-29 07:41:50
问题 Just for extending CheckBoxPreference or SwitchPreference on Android Lollipop, the widget (the checkbox or the switch) won't have animation anymore. I'd like to extend SwitchPreference to force api < 21 to use SwitchCompat instead of the default one they are using (which is obviously wrong). I am using the new AppCompatPreferenceActivity with appcompat-v7:22.1.1 but that doesn't seem to affect the switches. The thing is that with just extending those classes, without adding any custom layout

How do I call a specific PreferenceFragment from a PreferenceActivity?

筅森魡賤 提交于 2019-12-29 06:06:16
问题 I have a PreferenceActivity with several fragments: R.xml.preferences: (shortened for better readability): <?xml version="1.0" encoding="utf-8"?> <preference-headers xmlns:android="http://schemas.android.com/apk/res/android"> <header android:fragment="fragments.Fragment1" android:id="@+id/fragment1" [...] /> <header android:fragment="fragments.Fragment2" android:id="@+id/fragment2" [...] /> [...] </preference-headers> SettingsActivity : public class SettingsActivity extends PreferenceActivity