Error inflating class android.- widget.listview
Ist, habe ich mich durch einen Haufen anderer Leute Probleme und Erklärungen, und nichts funktioniert für mich. Die erste Aktivität aus dem Programm, das ist eine ListActivity, Schwierigkeiten beim aufblasen der xml-Datei. Die LogCat-Ausgabe ist:
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
Ich bin mir nicht ganz sicher, was Los ist. Ich habe in der Android-Manifest, und in Zeile 15 ist <application
dem scheint nicht so, als wäre es ein problem. Und Zeile 15 von meiner XML-Datei ist nur <ListView
. Ich werde Entsendung die gesamte XML-Datei in Fall gibt es etwas anderes gibt, dass scheint das problem zu sein.
<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>
Auch für den Datensatz, den stacktrace und bezieht sich auf Zeile 137 TeamDisplayActivity ist nur setContentView(R.layout.team_list_display)
. Jede Hilfe wäre wunderbar, ich bin wirklich nicht sicher, was schief gegangen ist. Vielen Dank im Voraus
- Poste deinen code als auch. Ihre
PhoneLayoutInflater
Klasse. - Das ist nicht meine Klasse, es ist ein Teil des Android-Bibliothek...
- klicken Sie auf die Zeile im logcat: Die eine, die Ihre packagename auf Sie und sehen, welche Linie es dauert Sie auf.
- wie bereits im ursprünglichen post, die Linie ist
setContentView
bla bla - ändern der id des listview-von
@+id/@android:id/list
zu@+id/list
Du musst angemeldet sein, um einen Kommentar abzugeben.
Diese Zeile nicht richtig freuen:
In der Regel ich denke, es wird angegeben, wie
Und versuchen Sie, id :
Verwenden Sie
@+id/@android:id/list
Ich denke, es muss
@+id/android:list
oder@+id/list
Können Sie hier sehen: https://stackoverflow.com/a/4355644/617801
@+id/@android:id/list
direkt von der SDK-website: developer.android.com/reference/android/app/ListActivity.html aus Ihrer Sicht MUSS ein ListView-Objekt mit der id "@android:id/list"android:id="@+id/@android:id/list" ändern Sie diese in android:id=" @+id/Liste1" .Dein problem binäre aufblasen Ausnahme aufgelöst wird .Und nicht immer versuchen, die Verwendung von android:id="@+id/list" innerhalb ListView . Durch die Verwendung noch Eine weitere option können Sie Ihre ListView-ich.e android:id="@id/android:list".
Ich hatte ein ähnliches problem, vielleicht hilft jemand anderes.
Ich versehentlich setzen
android:onClick="onClickExamplesMethod"
in der ListView. Nach dem entfernen dieser funktionierte es wieder.