易辰不呆
2022-04-14 21:37
采纳率: 100%
浏览 37
已结题

打开listview是app闪退,怎么办

打开listview是app闪退,怎么办

2022-04-14 21:25:11.073 3470-3470/com.example.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.myapplication, PID: 3470
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.listview.ListViewActivity}: android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class android.widget.ListView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2668)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2729)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1480)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6176)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
     Caused by: android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class android.widget.ListView
     Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class android.widget.ListView
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
        at android.view.LayoutInflater.createView(LayoutInflater.java:645)
        at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:699)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
        at com.example.myapplication.listview.ListViewActivity.onCreate(ListViewActivity.java:20)
        at android.app.Activity.performCreate(Activity.java:6692)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2621)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2729)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1480)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6176)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
     Caused by: android.content.res.Resources$NotFoundException: Drawable com.example.myapplication:drawable/list_item with resource ID #0x7f070070
     Caused by: android.content.res.Resources$NotFoundException: File res/drawable/list_item.xml from drawable resource ID #0x7f070070
        at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:725)
        at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:571)
        at android.content.res.Resources.loadDrawable(Resources.java:858)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:928)
        at android.widget.AbsListView.<init>(AbsListView.java:833)
        at android.widget.ListView.<init>(ListView.java:158)
        at android.widget.ListView.<init>(ListView.java:154)
        at android.widget.ListView.<init>(ListView.java:150)
2022-04-14 21:25:11.073 3470-3470/com.example.myapplication E/AndroidRuntime:     at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
        at android.view.LayoutInflater.createView(LayoutInflater.java:645)
        at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:699)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
        at com.example.myapplication.listview.ListViewActivity.onCreate(ListViewActivity.java:20)
        at android.app.Activity.performCreate(Activity.java:6692)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2621)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2729)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1480)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6176)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
     Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #7: <item> tag requires a 'drawable' attribute or child tag defining a drawable
        at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:183)
        at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:116)
        at android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130)
        at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1227)
        at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1200)
        at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:715)
            ... 34 more


```

3条回答 默认 最新

相关推荐 更多相似问题