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

Say I have an .xml file with a menu that looks like this. <?xml
I have settings that I store in my database. There is an entity class
I have some XML that I am using as an Android text menu. Here
I have this menu: <h:selectOneMenu value=#{ApplicationController.settings['SessionTTL']}> <f:selectItem itemValue=60 itemLabel=1 hour /> <f:selectItem itemValue=30 itemLabel=30
When I click Settings in my application's menu, app crash instantly. I don't have
I have various settings in my ccnet.config file and wish to pass them to
I have a settings.php file with parametric variables and a functions.php with well, some
I have a hardcoded li menu that is using filterable.js to filter a list
I have NSTableView object. I need to invoke the menu associated with it at
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.