Question

I've looked through a bunch of other people's problems and explanations, and nothing is working for me. The very first activity of my program, which is a ListActivity, is having trouble inflating its xml file. The LogCat output is:

08-01 08:36:17.800: E/AndroidRuntime(1935): FATAL EXCEPTION: main
08-01 08:36:17.800: E/AndroidRuntime(1935): java.lang.RuntimeException: Unable to start activity ComponentInfo{jamie.basketball.gui/jamie.basketball.gui.TeamDisplayActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class android.widget.ListView
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.os.Looper.loop(Looper.java:123)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.app.ActivityThread.main(ActivityThread.java:3683)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at java.lang.reflect.Method.invokeNative(Native Method)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at java.lang.reflect.Method.invoke(Method.java:507)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at dalvik.system.NativeStart.main(Native Method)
08-01 08:36:17.800: E/AndroidRuntime(1935): Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class android.widget.ListView
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.app.Activity.setContentView(Activity.java:1657)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at jamie.basketball.gui.TeamDisplayActivity.onCreate(TeamDisplayActivity.java:137)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-01 08:36:17.800: E/AndroidRuntime(1935):     ... 11 more
08-01 08:36:17.800: E/AndroidRuntime(1935): Caused by: java.lang.reflect.InvocationTargetException
08-01 08:36:17.800: E/AndroidRuntime(1935):     at java.lang.reflect.Constructor.constructNative(Native Method)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.view.LayoutInflater.createView(LayoutInflater.java:505)
08-01 08:36:17.800: E/AndroidRuntime(1935):     ... 22 more
08-01 08:36:17.800: E/AndroidRuntime(1935): Caused by: java.lang.NullPointerException
08-01 08:36:17.800: E/AndroidRuntime(1935):     at     android.content.res.AssetManager.getResourceTextArray(AssetManager.java:214)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.content.res.Resources.getTextArray(Resources.java:361)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.content.res.TypedArray.getTextArray(TypedArray.java:628)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.widget.ListView.<init>(ListView.java:168)
08-01 08:36:17.800: E/AndroidRuntime(1935):     at android.widget.ListView.<init>(ListView.java:159)
08-01 08:36:17.800: E/AndroidRuntime(1935):     ... 25 more

I'm not entirely sure what's going on. I've checked in the Android Manifest, and line 15 is <application which doesn't seem like it would be a problem. And line 15 of my XML file is just <ListView. I'm posting the entire XML file in case there's something else in there that seems to be the problem.

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <TextView
            android:id="@+id/num_of_teams"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:text="@string/debug"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <ListView
            android:id="@+id/@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/num_of_teams"
            android:layout_marginTop="5dp"
            android:entries="@layout/team_list_entry" >

        </ListView>

        <Button
            android:id="@+id/delete_team"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/@android:id/list"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="30dp"
            android:text="@string/delete_team" />

        <Button
            android:id="@+id/add_team"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="false"
            android:layout_alignParentTop="false"
            android:layout_below="@+id/@android:id/list"
            android:layout_marginLeft="50dp"
            android:layout_marginTop="30dp"
            android:layout_toRightOf="@id/delete_team"
            android:text="@string/add_team" />

    </RelativeLayout>

Also, for the record, the stacktrace that refers to line 137 of TeamDisplayActivity is just setContentView(R.layout.team_list_display). Any help would be wonderful, I'm really not sure what's gone wrong. Thanks in advance

Était-ce utile?

La solution

This line does not look right:

 android:entries="@layout/team_list_entry" 

Usually i think it is specified like

  android:entries="@array/servers" etc.

And try specifying id as :

android:id="@+id/list"  

Autres conseils

You use @+id/@android:id/list

I think it must be @+id/android:list or @+id/list

You can see here: https://stackoverflow.com/a/4355644/617801

android:id="@+id/@android:id/list" change this into android:id=" @+id/list1" .Your problem of binary inflate exception will get resolved .And don't ever try to use android:id="@+id/list" inside ListView . By using One more option you can create your ListView i.e android:id="@id/android:list".

I had a similiar problem maybe this helps someone else.

I accidentaly set android:onClick="onClickExamplesMethod" in the ListView. After removing this it worked again.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top