Questions tagged [preferencescreen]

Represents a top-level Preference that is the root of a Preference hierarchy. A PreferenceActivity points to an instance of this class to show the preferences.

Represents a top-level Preference that is the root of a Preference hierarchy. A PreferenceActivity points to an instance of this class to show the preferences. To instantiate this class, use createPreferenceScreen(Context).

This class can appear in two places:

  • When a PreferenceActivity points to this, it is used as the root and is not shown (only the contained preferences are shown).
  • When it appears inside another preference hierarchy, it is shown and serves as the gateway to another screen of preferences (either by showing another screen of preferences as a Dialog or via a startActivity(android.content.Intent) from the getIntent()). The children of this PreferenceScreen are NOT shown in the screen that this PreferenceScreen is shown in. Instead, a separate screen will be shown when this preference is clicked.
  • 201 questions
    1
    vote
    1 answer

    Reopening a Dialog from a EditTextPreference included on a PreferenceScreen

    I am trying to check the format of an input for an editText preference, in this case 24 hour format H:mm, and I want to force the edit dialog to appear again if there is an input format error. My idea is using a OnPreferenceChange listener running…
    user915335
    1
    vote
    1 answer

    androidx.preference.SwitchPreferenceCompat cannot be cast to androidx.preference.PreferenceGroup

    So I'm trying to make an options menu in my android app but when I click on it in the emulator the app crashes and I get the following error: androidx.preference.SwitchPreferenceCompat cannot be cast to androidx.preference.PreferenceGroup I don't…
    1
    vote
    1 answer

    How do I reference a preference option by key in my PreferenceScreen?

    I have a preference screen, and I want to disable visibility of a preference setting programaticaly in OnCreate depending of which version of android we are using. In order to do that I must be able to reference that particular preference…
    1
    vote
    1 answer

    EditText in PreferenceScreen and DialogPreference containing PreferenceScreen/CheckBoxPreference

    I have an application, where I want there to be several EditTexts on one screen, and then to the right of each, a button that will open a dialog for settings related to that EditText Issue is, I am trying to do this within a PreferenceActivity. I…
    Reed
    • 14,703
    • 8
    • 66
    • 110
    1
    vote
    1 answer

    How to make title of PreferenceScreen resizable?

    I've a preference screen for my app for which I've added the title. When the app gets opened in split screen and…
    Tom Taylor
    • 3,344
    • 2
    • 38
    • 63
    1
    vote
    1 answer

    Place Preference Screen Inside Fragment

    i want to know if there is any chance i could place my PreferenceScreen xml inside a ConstraintLayout fragment. I want my PreferenceScreen below the "Settings" text Here is my Fragment xml code:
    wiryadev
    • 1,089
    • 1
    • 11
    • 33
    1
    vote
    1 answer

    android - How to replicate Android 10 Settings

    Im currently developing an app which has a Settings menu. My App uses a dark theme as default theme, and i need to change Title and Summary text color. I also want to use icons like the Android 10 Settings menu: How can i replicate this menu and…
    Meltix
    • 436
    • 6
    • 22
    1
    vote
    1 answer

    How to change text color and background color of PreferenceScreen in Android

    How to change text and background color in a PreferenceScreen inflated by PreferenceFragmentCompat? Tried How to change the text color of PreferenceCategory/PreferenceScreen but the solution works in a Preference Activity and not in…
    Andrew Chelix
    • 1,012
    • 11
    • 16
    1
    vote
    2 answers

    How to use TextInputLayout in preferenceScreen

    I am trying to use TextInputLayout in a preference screen so as have a nice neat password box that has a show password option. I know there are ways and means of doing it with checkboxes and scripting but I would really love to be to just use the…
    poby
    • 1,572
    • 15
    • 39
    1
    vote
    2 answers

    How to Initialize Preferences Screen on First Invocation?

    I believe I am correctly initializing preferences from XML. My Preferences Screen also works properly and reflects the correct user selected settings. However, upon first invocation of that Preferences Screen, none of the settings are checked…
    1
    vote
    0 answers

    How to show the android preferences activity inside a popup window?

    I have a functioning settings activity (the default one that Android studio generates) which I would like to display inside a PopupWindow. I researched how to do this and most answers that show how to display an activity inside a popup window…
    1
    vote
    1 answer

    Turn Preference Screen into Button on/of interface

    My app has a Preference Screen that looks like this: But I need to create a new interface that look more like this: So a kind of button using on/off interface. Is there somehow a way to convert, by editing the code, the previous interface to the…
    TheOldBlackbeard
    • 395
    • 4
    • 22
    1
    vote
    2 answers

    How can i change fontFamily and textSize of SwitchPreference?

    How can i change those font attributes of a SwitchPreference? I already tried to use app:layout attribute with the following layout:
    Jan Möller
    • 301
    • 4
    • 19
    1
    vote
    1 answer

    Retrieve ListPreference inside PreferenceScreen

    How do I retrieve a ListPreference inside my PreferenceScreen? I have tried with the following, and they both throws null exception. findPreference(key) getPreferenceScreen().findPreference(key) private void loadLayout(int appWidgetId)…
    user634545
    • 9,099
    • 5
    • 29
    • 40
    1
    vote
    1 answer

    Divider between PreferenceScreen's

    After migrating to AndroidX and upping target SDK to 28 my SettingsPage has lost the dividers between the PreferenceScreen components and the text is not left aligned. Can anyone help? `
    André
    • 143
    • 1
    • 14