Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 695065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:55:15+00:00 2026-05-14T02:55:15+00:00

I have a settings menu that pops up and in it is a ListPreference

  • 0

I have a settings menu that pops up and in it is a ListPreference type menu. It is associated with a settings.xml file where there are ‘array-strings’ within it. It all works good but I don’t know how to retrieve the users preference.

As an example, let’s say the user picks a color (red, green, or blue). The list that I’ve made within my ‘array-strings’ contain the text red, green, and blue. Within my code, I would like to do something if the user has chosen red, something else if they choose blue, etc., etc. Would I use a ‘case’ statement or an ‘if’ statement? And most importantly, how would I retrieve the users preference – the key? (am I checking for a boolean?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:55:16+00:00Added an answer on May 14, 2026 at 2:55 am

    If you are using ListPreference and you haven’t disabled Persistent state, you can read the selected value from the SharedPreferences, after the setting is completed.

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    prefs.getString(yourkey, "defvalue");
    

    Also you can subscribe to onClick event, and you use the code Rpond mentioned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ClickOnce environment like this: \\Fileserver\ClickOnceApps\App1.application C:\Documents and Settings\user\Start Menu\Programs\publisher\app1.appref-ms My understanding
For my project I have settings that I added through the Settings in the
I have a settings file in my Winforms application called Settings.settings with a partial
I have some settings I need in a Javascript file -- servers to connect
I have some stuff in settings.py that I'd like to be able to access
We have a service that has some settings that are supported only over net.tcp.
I have a web service that needs different settings for different environments (debug, test,
I have a jquery accordion style menu that I'd like to add some shortcut
I have a hardcoded li menu that is using filterable.js to filter a list
I have a grouped tableview that is populated with XML data in one section.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.