Home
Blogs
Questions

Home

About Us

Blogs

Questions

Monetize

Post Job

banner

Questions about preferencescreen

Read more about preferencescreen

python (65.2k questions)

javascript (44.3k questions)

reactjs (22.7k questions)

java (20.8k questions)

c# (17.4k questions)

html (16.3k questions)

r (13.7k questions)

android (13k questions)

Questions - preferencescreen

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 ...
test-img

luca.04

java

android

xml

android-preferences

preferencescreen

Votes: 0

Answers: 1

Latest Answer

androidx.preference.SwitchPreferenceCompat cannot be cast to androidx.preference.PreferenceGroup The snippet setPreferencesFromResource(R.xml.preferences, rootKey) is what raises that as it expects ...
test-img

Zain

Modifying a preference value in a PreferenceScreen by code

I have a PreferenceScreen following the docs here and here. One of the options is a SwitchPreferenceCompat that does some risky work in my app, for example, to send sensitive information periodically....
test-img

Ton

android

androidx

preferencescreen

Votes: 0

Answers: 2

Latest Answer

You can modify it using the isChecked method. Here is an example doing that with a popup dialog like you described. This uses the onPreferenceChangeListener, and if the option is being disabled it sho...
test-img

Tyler V

Posts

Questions

Blogs

Where knowledge meets opportunity!

About

  • Company
  • Monetize your knowledge
  • Support

  • Platform

  • Terms & Conditions
  • Privacy statement
  • Cookie policy
  • Cookie option
  • OnlyCoders © 2025  |  All rights reserved