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 6930197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:24:59+00:00 2026-05-27T11:24:59+00:00

I am working on a PreferenceActivity for Android . I am following some of

  • 0

I am working on a PreferenceActivity for Android. I am following some of the code discussed here, which uses a ListPreference object. My preferences.xml is as follows:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

    <PreferenceCategory android:title="@string/prefs_app" >

      <ListPreference
        android:key="@string/gps_freq_main_key"
        android:title="@string/gps_freq_main_title"
        android:summary="@string/gps_freq_main_summary"
        android:entries="@array/gps_freq_main_entries"
        android:entryValues="@array/gps_freq_main_entryValues"
        android:defaultValue="every second (recommended)" />
    </PreferenceCategory>

    <PreferenceCategory
        android:title="@string/prefs_other">

        <PreferenceScreen
            android:key="@string/app_info_key"
            android:title="@string/app_info_title"
            android:summary="@string/app_info_summary">

          <Preference
            android:key="@string/app_copyright_key"
            android:title="@string/app_copyright_title"
            android:summary="@string/app_copyright_summary" />

          <Preference
            android:key="@string/app_version_key"
            android:title="@string/app_version_title" />

    </PreferenceScreen>
</PreferenceCategory>

All of the strings mentioned are defined in res/values/strings.xml. The two arrays are defined in res/values/arrays.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <integer-array name="gps_freq_main_entries">
    <item>1</item>
    <item>2</item>
    <item>3</item>
    <item>4</item>
    <item>5</item>
    <item>10</item>
    <item>20</item>
    <item>30</item>
    <item>60</item>
    <item>120</item>
    <item>300</item>
    <item>600</item>
    <item>900</item>
    <item>1200</item>
  </integer-array>
  <string-array name="gps_freq_main_entryValues">
    <item>every second (recommended)</item>
    <item>2 seconds</item>
    <item>3 seconds</item>
    <item>4 seconds</item>
    <item>5 seconds</item>
    <item>10 seconds</item>
    <item>20 seconds</item>
    <item>30 seconds</item>
    <item>1 minute</item>
    <item>2 minutes</item>
    <item>5 minutes</item>
    <item>10 minutes</item>
    <item>15 minutes</item>
    <item>30 minutes</item>
  </string-array>

</resources>

The problem arises when I select this ListPreference (the Activity launches correctly, and all other preferences work). There is no code in my PreferenceActivity that affects this ListPreference. Here is my logcat:

08-24 15:34:49.428: ERROR/AndroidRuntime(1250): Uncaught handler: thread main exiting due to uncaught exception
08-24 15:34:49.478: ERROR/AndroidRuntime(1250): java.lang.NullPointerException
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:351)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.widget.AbsListView.obtainView(AbsListView.java:1269)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1117)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.widget.ListView.onMeasure(ListView.java:1030)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.view.View.measure(View.java:7115)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2875)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:888)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:350)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.view.View.measure(View.java:7115)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2875)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:888)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:350)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.view.View.measure(View.java:7115)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2875)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.view.View.measure(View.java:7115)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2875)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.view.View.measure(View.java:7115)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.view.ViewRoot.performTraversals(ViewRoot.java:698)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1482)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.os.Looper.loop(Looper.java:123)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at android.app.ActivityThread.main(ActivityThread.java:3948)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at java.lang.reflect.Method.invokeNative(Native Method)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at java.lang.reflect.Method.invoke(Method.java:521)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
08-24 15:34:49.478: ERROR/AndroidRuntime(1250):     at dalvik.system.NativeStart.main(Native Method)

Any help would be greatly appreciated!

  • 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-27T11:24:59+00:00Added an answer on May 27, 2026 at 11:24 am

    I just ran into this problem with a different application. To solve it, I used a string-array instead of an integer array. I’m not sure why this is needed, but it worked.

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

Sidebar

Related Questions

I have a working user-preferences screen which is defined in user_prefs.xml. The xml is
Working with python interactively, it's sometimes necessary to display a result which is some
Working on some code and I'm given the error when running it from the
Working through Pro ASP.NET MVC book and I got the following code snippet that
Working SQL The following code works as expected, returning two columns of data (a
Working on my first Android app here. I've searched and tried everything I can
In an Android app I let the user edit his preferences by running a
in my application I call startActivityForResult( new Intent(this, ShowPreferencesActivity.class), <some code>); the activity is
I have been attempting to use an android.preference.DialogPreference inflated from XML, but the documentation
I'm a noob working on my first app that consists of the following: Main

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.