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

  • Home
  • SEARCH
  • 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 3396168
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:22:32+00:00 2026-05-18T04:22:32+00:00

I am working to implement some simple preferences to an app I have and

  • 0

I am working to implement some simple preferences to an app I have and I am trying to figure out how to use a preference to manipulate a view defined in an XML file. I have a List with the following LinearLayout (player_row.xml) being used for each row:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="horizontal"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <ImageView android:id="@+id/player_icon"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="center"/>
  <TextView android:id="@+id/player_name"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:textSize="30sp"
   android:textColor="#F0F0F0"
   android:layout_weight="1"
   android:layout_marginLeft="5dp"/>
  <TextView android:id="@+id/player_score"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:textSize="30sp"
   android:textColor="#F0F0F0"/>
</LinearLayout>

Right now I am specifying the textSize attribute manually. I’d like to create a preference menu that lets the user select from several options, say “Small”, “Medium”, and “Large”. I figure I should be able to set up the arrays for the entry and font sizes and then reference that in player_row.xml, but I don’t seem to be able to.

preferences.xml:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
   android:key="preference_main">
   <ListPreference
      android:key="fontSizePreference"
      android:title="Font size"
      android:entries="@array/fontSizeList"
      android:entryValues="@array/fontSizeList_Values"/>
</PreferenceScreen>

arrays.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <string-array name="fontSizeList">
    <item>Small</item>
    <item>Medium</item>
    <item>Large</item>
  </string-array>
  <string-array name="fontSizeList_Values">
    <item>22sp</item>
    <item>26sp</item>
    <item>30sp</item>
  </string-array>
</resources>

If this can’t be done, what is the appropriate way to configure a layout using preferences? My searching has led me to find multiple resources on accessing the preferences programmatically but none of that seems to be the appropriate way to configure a layout defined in an XML file.

  • 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-18T04:22:33+00:00Added an answer on May 18, 2026 at 4:22 am

    I think the procedure you are looking for is:

    1. Create settings screen & activity
    2. Once the user saves settings, let your backing PreferenceActivity save the settings into a file (using getPreferences(MODE_PRIVATE).edit().putString(PREF_FONT_SIZE, yourSetting).commit()
    3. In your main activity#onCreate, load the layout using setContentView
    4. Load your preferences there as well
    5. Get the views via findViewById and set the font size as it’s loaded from the preferences
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a fairly complicated app and am trying to figure out how
I'm trying to implement some rudimentary tabs in a Cocoa editor I'm working on.
I am working on a simple Core Data app. I have two classes: Client
I'm working on a project that's trying to implement some editing features using a
Good Evening, I have been trying to implement a simple Android(tm) application that utilizes
I am trying to implement some very simple Data Binding in my User Control
since Google translate api will stop working i'm trying to implement some jquery code
I have a page where I am trying to implement a simple two tab
Working on a project at the moment and we have to implement soft deletion
I'm trying to implement a binding between some custom-built models and just beginning to

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.