Questions tagged [android-preferences]
1916 questions
43
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
- 819
- 1
- 8
- 14
39
votes
6 answers
How to use Percentage for android layout?
How can we use percentage values for android view elements? something like this

masoud p
- 503
- 1
- 7
- 15
38
votes
7 answers
PreferenceFragmentCompat has padding on PreferenceCategory that I can't get rid of
So I've been trying to create a settings activity using androidx.preference.PreferenceFragmentCompat and it's all working fine.
However for some reason there is some padding present on both the preference categories and the preferences themselves. I…

Henry Twist
- 5,666
- 3
- 19
- 44
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?

QuickNick
- 1,921
- 2
- 15
- 30
37
votes
3 answers
PreferenceFragment - Difference between getPreferenceManager() and getPreferenceScreen()?
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…

XåpplI'-I0llwlg'I -
- 21,649
- 28
- 102
- 151
36
votes
7 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,125
- 1
- 14
- 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…

Ifrit
- 6,791
- 8
- 50
- 79
34
votes
4 answers
How to fill ListPreference dynamically when onPreferenceClick is triggered?
I have a preference activity that has a language as ListPreference which displays the available language list. I can fill the list when onCreate is called, but I want to fill the list when the user clicks on it.
this is the java code :
public…

Abdullah
- 5,445
- 10
- 41
- 48
34
votes
4 answers
Nested preferences.xml
Is it somehow possible to include one preferences.xml into another, like it can be done for layouts with the tag?
Let's say:

GrAnd
- 10,141
- 3
- 31
- 43
33
votes
4 answers
Custom PreferenceCategory Headings
I have a simple preference screen defined like this

Josh
- 16,286
- 25
- 113
- 158
31
votes
8 answers
In android is there any way to preserve SharedPreferences after an uninstall
I am keeping some application meta data in SharedPreferences. Whenever I uninstall the application and reinstall it, the SharedPreferences are deleted.
Is there any way to get that to remain, so that if the user does an uninstall and reinstall, they…

Victor Grazi
- 15,563
- 14
- 61
- 94
31
votes
4 answers
Run a piece of code only once when an application is installed
I want to run a piece of code only once in my application and is when i run it for the first time (newly installed app). How could i do this, can anyone explain giving a piece of code.
Actually, in my android project i want to create database and…

Chintan Soni
- 24,761
- 25
- 106
- 174
29
votes
2 answers
Why won't Fragment retain state when screen is rotated?
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…

XåpplI'-I0llwlg'I -
- 21,649
- 28
- 102
- 151
27
votes
10 answers
How to manage dividers in a PreferenceFragment?
I started dealing with preferences in a PreferenceFragment. Here's what I have:
I'm trying to:
get rid of the dividers between items. I suppose this can be defined from styles, but I can't figure out how. I tried getting the
preference ListView at…

natario
- 24,954
- 17
- 88
- 158
27
votes
3 answers
Default value of Android preference
How do you get the default value of an Android preference defined in XML? I don't want to repeat the definition of the default value in both the code and the preferences XML.

hpique
- 119,096
- 131
- 338
- 476