android-preferences

Why SwitchPreference is not showing animation when switching from on to off & vice versa?

谁都会走 提交于 2019-11-30 13:03:21
问题 I've made a SwitchPreference for my app's preferences . The problem is that the SwitchPreference is not showing animation when I'm switching between on & off, rather, it is switching with a sudden jerk. Here's preferences.xml file's code: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <SwitchPreference android:id="@+id/notification" android:key="notification" android:title="@string/notification" android:defaultValue="true"/

Start Activity from preference screen (intent defined in xml file)

旧街凉风 提交于 2019-11-30 11:58:43
In my preference file I go this <PreferenceCategory android:title="Title" > <Preference android:title="title" > <intent android:action="com.my.package.MainActivity" /> </Preference> </PreferenceCategory> The activity is created in the manifest file , but I still get android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.my.package.MainActivity } How can I start activity from preferences screen ? I had the same issue but none of the solutions i searched on stackoverflow solved my activitynotfound Exception. Here is the working solution i found from here :

Android Widget: Show configuration activity before widget is added to the screen

99封情书 提交于 2019-11-30 11:49:42
I have an Android Widget that uses web services to retrieve and display the data on the widget. The widget has a configuration activity that extends PreferenceActivity . The configuration activity starts up as soon as the widget is installed, which is the desired behavior for this widget. The problem is, whenever a widget is added to the home screen, the widget attempts to update iteself before the configuration activity is started/completed which may potentially lead to a long delay (several seconds). The configuration activity should occur before the widget attempts to update itself anytime

How to enable a preference in my android application when other preference is disabled?

吃可爱长大的小学妹 提交于 2019-11-30 10:58:42
I have used PreferenceActivity to have preference in my android application. I want one preference say "pref 2" to be enabled when other preference say "pref 1" is NOT checked and "pref 2" to be disabled when "pref 1" is checked. i.e. exactly opposite of the android:dependancy attribute. How can I do that? David Hedlund I don't think there's any out-of-the-box solution for it, i.e. an inverted dependancy attribute. But there's always the click-listener: preference1.setOnPreferenceClickListener(pref1_click); .... private OnPreferenceClickListener pref1_click = new OnPreferenceClickListener() {

Nested preferences.xml

痴心易碎 提交于 2019-11-30 10:56:55
问题 Is it somehow possible to include one preferences.xml into another, like it can be done for layouts with the <include /> tag? Let's say: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen android:title="@string/pref_group_title_visual"> <include preferences_filename="xml/pref_visual"/> </PreferenceScreen> ... 回答1: Solution here it is to inflate both preference files from PreferencesActivity. For example:

How to show and hide preferences on Android dynamically?

淺唱寂寞╮ 提交于 2019-11-30 10:46:30
问题 Is there a way to dynamically show and hide preferences? In my case, I have a checkbox preference that would disable or enable one of 2 preference groups ("with-" and "without-handicap" groups). While this would be the ideal GUI in a desktop environment, the "with-handicap" takes up nearly the whole screen, while the other, "without-handicap" takes up only a small portion of the screen. Rather than showing both groups at the same time, I'd like to show only one of them at a time, and

Android: how to get list of all preference xml's for my app and read them?

怎甘沉沦 提交于 2019-11-30 09:36:00
how to get list of all application preferences for application, 1. I am saving shared preference in this manner 2. I know that they are in data/data/app_packagename/shared_prefs 3. THE PROBLEM: But how to get list of all preference xml files in a spinner and read each preference, i searched in SO , but i did not found any help regarding this, how to do read all preference xml files in my application directory and access the preferences? P.S: I am aware of SharedPreference.getAll(); , will be enough to read once i get the file? I have wrote in bits(Rough Code), it give error when tried to run,

How to right align PreferencesActivity in android?

寵の児 提交于 2019-11-30 08:33:11
I have PreferencesActivity which I need it to be right aligned because I want to use Arabic language, I tried to use android:layout_gravity="right" for PreferenceScreen but it didn't work. This is my XML: <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:layout_gravity="right"> <PreferenceCategory android:title="General Settings"> <CheckBoxPreference android:title="Full Screen" android:defaultValue="false" android:summary="Always view as Full Screen" android:key="fullScreenPref" /> <Preference android:title="Report Bugs" android:summary="Notify us for any

PreferenceFragment - Difference between getPreferenceManager() and getPreferenceScreen()?

风流意气都作罢 提交于 2019-11-30 07:51:39
I've implemented my own PreferenceFragment subclass (detailed here ), and want to listen for preference changes within it. PreferenceFragment provides you with two ways of doing this: getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); and getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); Which one should be used? What's the difference? I don't really understand the distinction made in the Android docs . The core difference is in their names, PreferenceManger grants access to different functionalities to the

How to remove Android preferences from the screen

家住魔仙堡 提交于 2019-11-30 06:49:01
I'm trying to remove a preference from the screen so it isn't visible if the user is using an SDK greater than 2.2. I've found several answers saying that getPreferenceScreen().removePreference(thePreference) will work, but I'm getting FALSE returned every time I try it. Am I using it in the wrong place? Any clue from my code? public class Preferences extends PreferenceActivity implements OnSharedPreferenceChangeListener { private static final String POLLING_PREFERENCE = "update_frequency_list"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);