09-26 16:24:55.490 15382-15382/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.recyclervieww, PID: 15382
android.view.InflateException: Binary XML file line #8: Error inflating class ImageView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at com.example.recyclervieww.RecyclerViewAdapter.onCreateViewHolder(RecyclerViewAdapter.java:36)
at com.example.recyclervieww.RecyclerViewAdapter.onCreateViewHolder(RecyclerViewAdapter.java:19)
at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7069)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6233)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6116)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6112)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4132)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3849)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4402)
at android.view.View.layout(View.java:16019)
at android.view.ViewGroup.layout(ViewGroup.java:5206)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1195)
at android.view.View.layout(View.java:16019)
at android.view.ViewGroup.layout(ViewGroup.java:5206)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:639)
at android.widget.FrameLayout.onLayout(FrameLayout.java:574)
at android.view.View.layout(View.java:16019)
at android.view.ViewGroup.layout(ViewGroup.java:5206)
at androidx.appcompat.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:446)
at android.view.View.layout(View.java:16019)
at android.view.ViewGroup.layout(ViewGroup.java:5206)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:639)
at android.widget.FrameLayout.onLayout(FrameLayout.java:574)
at android.view.View.layout(View.java:16019)
at android.view.ViewGroup.layout(ViewGroup.java:5206)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1959)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1813)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1722)
at android.view.View.layout(View.java:16019)
at android.view.ViewGroup.layout(ViewGroup.java:5206)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:639)
at android.widget.FrameLayout.onLayout(FrameLayout.java:574)
at android.view.View.layout(View.java:16019)
at android.view.ViewGroup.layout(ViewGroup.java:5206)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2487)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2184)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1296)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6665)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:800)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:572)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:786)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:218)
at android.app.ActivityThread.main(ActivityThread.java:5657)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.o
答案 0 :(得分:0)
在我的案例中,膨胀R.Layout.RecyclerView xml时出错。 只需关闭项目,然后再次打开,然后让android studio对其进行修复即可。