preferenceactivity

getActionBar() returns null in PreferenceActivity (AppCompat-v7 21)

烈酒焚心 提交于 2019-12-17 18:48:43
问题 I have implemented DoneBar (two buttons in actionbar) in PreferenceActivity as provided in v20 sdk samples, but after updating SDK and AppCompat to version 21 my app crashes at java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayOptions(int, int)' on a null object reference That is because getActionBar() returns null. And There is no getSupportActionBar() as in ActionBarActivity . So my question is how to get that actionbar object in

Why won't Fragment retain state when screen is rotated?

你说的曾经没有我的故事 提交于 2019-12-17 17:30:48
问题 I've been having some trouble getting some custom DialogPreference subclasses inside a PreferenceFragment to remain visible when the screen is rotated. I don't experience this problem when using a PreferenceActivity, so I don't know whether it's an Android bug or a problem with my code, but I'd like someone to confirm whether they are having the same experience. To test this, first create a preference screen containing at least one DialogPreference (it doesn't matter which subclass). Then

How to detect if changes were made in the preferences?

心不动则不痛 提交于 2019-12-17 08:48:05
问题 I have a class that extends PreferenceActivity and shows the preference screen of my app. Is it possible to check if any changes were made to the preferences? This helps... http://developer.android.com/reference/android/content/SharedPreferences.OnSharedPreferenceChangeListener.html Other related post: SharedPreferences.onSharedPreferenceChangeListener not being called consistently public class PreferenceClass extends PreferenceActivity { OnSharedPreferenceChangeListener listener; public void

How to detect if changes were made in the preferences?

痞子三分冷 提交于 2019-12-17 08:47:45
问题 I have a class that extends PreferenceActivity and shows the preference screen of my app. Is it possible to check if any changes were made to the preferences? This helps... http://developer.android.com/reference/android/content/SharedPreferences.OnSharedPreferenceChangeListener.html Other related post: SharedPreferences.onSharedPreferenceChangeListener not being called consistently public class PreferenceClass extends PreferenceActivity { OnSharedPreferenceChangeListener listener; public void

How to detect if changes were made in the preferences?

99封情书 提交于 2019-12-17 08:47:35
问题 I have a class that extends PreferenceActivity and shows the preference screen of my app. Is it possible to check if any changes were made to the preferences? This helps... http://developer.android.com/reference/android/content/SharedPreferences.OnSharedPreferenceChangeListener.html Other related post: SharedPreferences.onSharedPreferenceChangeListener not being called consistently public class PreferenceClass extends PreferenceActivity { OnSharedPreferenceChangeListener listener; public void

how to access widgets set in layout using preference activity

ε祈祈猫儿з 提交于 2019-12-13 12:17:30
问题 i am creating preference Activity, in that i am adding custom preference screen using layout and i want to update values dynamically. Here's the code : <PreferenceCategory android:key="more_category" android:title="More Wallpapers " > <Preference android:key="more_apps" android:layout="@layout/more_apps" /> Here is my layout more_apps.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"

How to create settings screen in android app?

廉价感情. 提交于 2019-12-13 09:22:24
问题 How do I create a settings screen? Should I use PreferenceActivity or PreferenceFragment ? Note- Documentation wasn't helpful What I've already tried: Using PreferenceActivity but couldn't implement a simple toolbar in it. Using PreferenceFragment but was too complex to understand. What I want is a simple implementation using PreferenceFragment 回答1: On Android 3.0 and later, you should use a PreferenceFragment that displays your app settings. Create a SettingsFragment: public static class

Setting preference layout and changing the attribute in it

笑着哭i 提交于 2019-12-12 08:42:53
问题 is it possible to access programmatically a layout which is set to a Preference? Here is what I have, a very simple project - proof of concept The Preference Activity: package com.example; import android.os.Bundle; import android.preference.PreferenceActivity; import android.util.Log; import android.view.View; public class PreferenceExampleActivity extends PreferenceActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super

What method is called when PreferenceActivity saves values

自作多情 提交于 2019-12-12 01:39:12
问题 I have an app which uses PreferenceActivity to define time period to run scheduled tasks. But I can't the right method to Override in PreferenceActivity to make tasks rescheduled on period values changed. Does anyone know what method is called when PreferenceActivity saves values? I am using API 8 level and seems that onSaveInstanceState(Bundle outState) is not that I am looking for. 回答1: There is no callback for changed preferences in a PreferenceActivity. But you can use the normal

How can I use another Color Picker without preferenceActivity?

限于喜欢 提交于 2019-12-11 19:52:11
问题 I have a color picker which I use in sharedPrefereces. With the default colorpicker I managed to acheive what I want, but I noticed there is no black or white colors. http://www.yougli.net/android/a-photoshop-like-color-picker-for-your-android-application/ I would like to use this code but in the last rows, he shows an example, where I can see it is attached to a preferenced Screen. Instead of it I use my own activity with buttons where using shared Preferences I can save datas/values (so its