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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:10:54+00:00 2026-06-03T12:10:54+00:00

I want to implement a preference screen. So I followed basically the example from

  • 0

I want to implement a preference screen. So I followed basically the example from the developer docs.
When I start the Activity I see the header list, with one header (this part seems to work). But as soon I click this header the Activity crashed with below log.

I searched SO and google, but couldn’t find any further information on this error.

I tried to shorten preference_appearance_screen.xml to one CheckBoxPreference item. Still same error on XML Line 18. So I guess that the error is not to be found in this file.

My activity class:

public class TrainerPreferenceActivity extends PreferenceActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onBuildHeaders(List<Header> target) {
        loadHeadersFromResource(R.xml.preference_headers, target);
    }

    public static class AppearancePrefFragment extends PreferenceFragment {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            addPreferencesFromResource(R.xml.preference_appearance_screen);
        }
    }
}

preference_headers.xml file:

<?xml version="1.0" encoding="utf-8"?>
<preference-headers
    xmlns:android="http://schemas.android.com/apk/res/android">
    <header android:fragment=".TrainerPreferenceActivity$AppearancePrefFragment"
           android:title="Appearance"
           android:summary="An example of some preferences." />
</preference-headers>

preference_appearance_screen.xml file:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory 
        android:title="@string/pref_app_cat_theme">
    </PreferenceCategory>
    <PreferenceCategory 
        android:title="@string/pref_app_cat_background">
        <CheckBoxPreference 
            android:key="@string/pref_app_bg_iscustom_key" 
            android:title="@string/pref_app_bg_iscustom_title"
            android:summary="An example of some preferences."/>
        <CheckBoxPreference 
            android:key="@string/pref_app_bg_hascolor_key" 
            android:title="@string/pref_app_bg_hascolor_title"
            android:summary="An example of some preferences."/>  
        <CheckBoxPreference 
            android:key="@string/pref_app_bg_hasimage_key" 
            android:title="@string/pref_app_bg_hasimage_title"
            android:summary="An example of some preferences."/>
    </PreferenceCategory>
    <PreferenceCategory 
        android:title="@string/pref_app_cat_behavior">
        <CheckBoxPreference 
            android:key="@string/pref_app_orientationisenabled_key" 
            android:title="@string/pref_app_orientationisenabled_title"
            android:summary="An example of some preferences."/>        
        <CheckBoxPreference 
            android:key="@string/pref_app_gestureisenabled_key" 
            android:title="@string/pref_app_gestureisenabled_title"
            android:summary="An example of some preferences."/>
   </PreferenceCategory>
</PreferenceScreen>

LogCat:

04-30 17:22:01.215: E/AndroidRuntime(16775): FATAL EXCEPTION: main
04-30 17:22:01.215: E/AndroidRuntime(16775):
java.lang.RuntimeException: Binary XML file line #18: You must supply
a layout_width attribute. 04-30 17:22:01.215: E/AndroidRuntime(16775):
at
android.content.res.TypedArray.getLayoutDimension(TypedArray.java:491)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:5318)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.view.ViewGroup$LayoutParams.(ViewGroup.java:5271) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.widget.AbsListView$LayoutParams.(AbsListView.java:5718)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.AbsListView.generateLayoutParams(AbsListView.java:5355)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.AbsListView.generateLayoutParams(AbsListView.java:86)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.view.LayoutInflater.inflate(LayoutInflater.java:477) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.view.LayoutInflater.inflate(LayoutInflater.java:396) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.preference.Preference.onCreateView(Preference.java:474) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.preference.Preference.getView(Preference.java:451) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.preference.PreferenceGroupAdapter.getView(PreferenceGroupAdapter.java:221)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.AbsListView.obtainView(AbsListView.java:2033) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.widget.ListView.onMeasure(ListView.java:1127) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.view.View.measure(View.java:12723) 04-30 17:22:01.215:
E/AndroidRuntime(16775): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1369)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.LinearLayout.measureVertical(LinearLayout.java:660)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.LinearLayout.onMeasure(LinearLayout.java:553) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.view.View.measure(View.java:12723) 04-30 17:22:01.215:
E/AndroidRuntime(16775): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.FrameLayout.onMeasure(FrameLayout.java:293) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.view.View.measure(View.java:12723) 04-30 17:22:01.215:
E/AndroidRuntime(16775): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1369)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.LinearLayout.measureVertical(LinearLayout.java:660)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.LinearLayout.onMeasure(LinearLayout.java:553) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.view.View.measure(View.java:12723) 04-30 17:22:01.215:
E/AndroidRuntime(16775): at
android.widget.LinearLayout.measureHorizontal(LinearLayout.java:999)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.LinearLayout.onMeasure(LinearLayout.java:555) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.view.View.measure(View.java:12723) 04-30 17:22:01.215:
E/AndroidRuntime(16775): at
android.widget.LinearLayout.measureVertical(LinearLayout.java:812)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.LinearLayout.onMeasure(LinearLayout.java:553) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.view.View.measure(View.java:12723) 04-30 17:22:01.215:
E/AndroidRuntime(16775): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.FrameLayout.onMeasure(FrameLayout.java:293) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.view.View.measure(View.java:12723) 04-30 17:22:01.215:
E/AndroidRuntime(16775): at
android.widget.LinearLayout.measureVertical(LinearLayout.java:812)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.LinearLayout.onMeasure(LinearLayout.java:553) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.view.View.measure(View.java:12723) 04-30 17:22:01.215:
E/AndroidRuntime(16775): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.widget.FrameLayout.onMeasure(FrameLayout.java:293) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2092)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.view.View.measure(View.java:12723) 04-30 17:22:01.215:
E/AndroidRuntime(16775): at
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1064)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.os.Handler.dispatchMessage(Handler.java:99) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
android.os.Looper.loop(Looper.java:137) 04-30 17:22:01.215:
E/AndroidRuntime(16775): at
android.app.ActivityThread.main(ActivityThread.java:4424) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
java.lang.reflect.Method.invokeNative(Native Method) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
java.lang.reflect.Method.invoke(Method.java:511) 04-30 17:22:01.215:
E/AndroidRuntime(16775): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-30 17:22:01.215: E/AndroidRuntime(16775): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 04-30
17:22:01.215: E/AndroidRuntime(16775): at
dalvik.system.NativeStart.main(Native Method)

  • 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-06-03T12:10:55+00:00Added an answer on June 3, 2026 at 12:10 pm

    Alright, I set up a quick test project, but I haven’t been able to reproduce the error – it displays and works fine on my Galaxy Nexus. What device are you running this on, and have you tried any others/emulators?

    The only possibly related issue I could find is this style/theming-related one, which seems to pop up every here and there. Have you made any customizations? If so, try running above code as ‘vanilla’ as possible to see if that makes a difference.

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

Sidebar

Related Questions

I want to implement robot's path planning subsystem. I'm going to use A* from
I want implement in my software solution an VBA editor but in c# 3.0.
given this class definition: public class Frame { IFrameStream CapturedFrom; } I want implement
Microsoft has announce that WindowsLiveID become a OpenID provider . I want implement it
I want to implement an autocomplete feature with images in my website. I would
I want to implement file uploading with behaviour which is commonly seen in various
I want to implement a function in the base class but I also want
I want to implement a Facebook updates(user action and notifications) on my web application
I want to implement a basic search/replace translation table in C; that is, it
I want to implement dynamic, client side file generation in javascript. Is it possible?

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.