Questions tagged [preferenceactivity]

PreferenceActivity in Android is a base class for an activity to show a hierarchy of preferences to the user

680 questions
381
votes
6 answers

How do I get the SharedPreferences from a PreferenceActivity in Android?

I am using a PreferenceActivity to show some settings for my application. I am inflating the settings via a xml file so that my onCreate (and complete class methods) looks like this: public class FooActivity extends PreferenceActivity { …
Dave
  • 3,933
  • 3
  • 15
  • 8
128
votes
8 answers

How to add Action Bar from support library into PreferenceActivity?

Action Bar compatibility has been added into support library, revision 18. It now has ActionBarActivity class for creating activities with Action Bar on older versions of Android. Is there any way to add Action Bar from support library into…
84
votes
8 answers

No ActionBar in PreferenceActivity after upgrade to Support Library v21

After I upgraded to the Support Library v21 my ActionBar in my PreferenceActivity is gone. Did I miss some attributes in my theme to activate it again? I had some similar trouble with a black ActionBar. I also tried to add it a little hackish by…
76
votes
2 answers

How to detect if changes were made in the preferences?

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…
68
votes
12 answers

Android: Start Activity from preferences.xml

I would like to start an Activity from a default preferences.xml, with < intent > tag. The Activities are well tested, the problem is not with that. (I'm extending PreferenceActivity in my app, so the preferences.xml is "comes" with that) Please…
Lama
  • 1,293
  • 3
  • 11
  • 10
57
votes
6 answers

Android: "BadTokenException: Unable to add window; is your activity running?" at showing dialog in PreferenceActivity

I'd like to ask for some help: In my app, I have only one activity, a PreferenceActivity (don't need other, it's just a simple background-sync app, so the PrefsActivity is the Main/Launcher). After the user setup preferences, checks a…
Lama
  • 1,293
  • 3
  • 11
  • 10
57
votes
5 answers

Android: Creating custom preference

Is it possible to create an individual preference in an PreferenceScreen? I would like to code color settings like that: I know that choosing the color is easy realizable with the ListPreference, but it would be awesome with that kind of…
Jonas
  • 1,362
  • 3
  • 17
  • 27
51
votes
6 answers

PreferenceActivity: save value as integer

Using a simple EditTextPreference in my preferences activity: Is there a way…
Laimoncijus
  • 8,187
  • 9
  • 55
  • 80
46
votes
4 answers

When to use CheckBox and when Switch

Can anyone can tell me when to use Checkbox and when Switch? I mean, what is the real login difference between the two in the context of a PreferenceActivity? For example, will you change the next section to Checkboxes? It's part of a set, but using…
David
  • 34,355
  • 30
  • 113
  • 139
42
votes
5 answers

Number Preferences in Preference Activity in Android

What I want to do is I am working on a game of life program. I want to take the time delay and make it a preference, but I want to make it available for people to type in a specific time. The number can be in miliseconds or seconds. However I'm…
Kinglink
  • 711
  • 1
  • 7
  • 14
37
votes
5 answers

Launch new activity from PreferenceActivity

Good day, friends. I have a PreferenceActivity, it is filled from XML file. When we press one item, we should launch new activity. How to do it? What should I write in XML-file or in the Java-class?
36
votes
6 answers

How to show and hide preferences on Android dynamically?

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…
Japtar
  • 1,085
  • 1
  • 13
  • 24
36
votes
2 answers

Issues with dual-pane preference screens

Problem Rotating a device from a one-pane portrait PreferenceScreen to a two-pane landscape PreferenceScreen, causes landscape to only show as one-pane. Does NOT occur when viewing the headers screen. Setup This is for ICS and up only. I have a…
36
votes
6 answers

PreferenceActivity Android 4.0 and earlier

Trying the different preference activities in the ApiDemos for Android 4.0, I see in the code that some methods are deprecated in PreferencesFromCode.java, for example. So my question is: if I use PreferenceFragment, will it work for all version or…
just_user
  • 10,086
  • 14
  • 78
  • 119
33
votes
4 answers

Custom PreferenceCategory Headings

I have a simple preference screen defined like this
Josh
  • 15,587
  • 25
  • 107
  • 149
1
2 3
45 46