Android Question Error with swipe refresh and recycler view

mehdipass

Active Member
Why does this error happen?
Error:
Exception java.lang.IllegalStateException: ViewHolder views must not be attached when created. Ensure that you are not passing 'true' to the attachToRoot parameter of LayoutInflater.inflate(..., boolean attachToRoot)
  at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder (RecyclerView.java:7297)
  at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline (RecyclerView.java:6416)
  at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:6300)
  at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:6296)
  at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next (LinearLayoutManager.java:2330)
  at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk (LinearLayoutManager.java:1631)
  at androidx.recyclerview.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1591)
  at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:668)
  at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2 (RecyclerView.java:4309)
  at androidx.recyclerview.widget.RecyclerView.dispatchLayout (RecyclerView.java:4012)
  at androidx.recyclerview.widget.RecyclerView.onLayout (RecyclerView.java:4578)
  at android.view.View.layout (View.java:24461)
  at android.view.ViewGroup.layout (ViewGroup.java:7412)
  at androidx.swiperefreshlayout.widget.SwipeRefreshLayout.onLayout (SwipeRefreshLayout.java:689)
  at android.view.View.layout (View.java:24461)
  at android.view.ViewGroup.layout (ViewGroup.java:7412)
  at anywheresoftware.b4a.BALayout.onLayout (BALayout.java:60)
  at android.view.View.layout (View.java:24461)
  at android.view.ViewGroup.layout (ViewGroup.java:7412)
  at anywheresoftware.b4a.BALayout.onLayout (BALayout.java:60)
  at android.view.View.layout (View.java:24461)
  at android.view.ViewGroup.layout (ViewGroup.java:7412)
  at anywheresoftware.b4a.BALayout.onLayout (BALayout.java:60)
  at android.view.View.layout (View.java:24461)
  at android.view.ViewGroup.layout (ViewGroup.java:7412)
  at anywheresoftware.b4a.BALayout.onLayout (BALayout.java:60)
  at android.view.View.layout (View.java:24461)
  at android.view.ViewGroup.layout (ViewGroup.java:7412)
  at anywheresoftware.b4a.BALayout.onLayout (BALayout.java:60)
  at android.view.View.layout (View.java:24461)
  at android.view.ViewGroup.layout (ViewGroup.java:7412)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:374)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:312)
  at android.view.View.layout (View.java:24461)
  at android.view.ViewGroup.layout (ViewGroup.java:7412)
  at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1829)
  at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1673)
  at android.widget.LinearLayout.onLayout (LinearLayout.java:1582)
  at android.view.View.layout (View.java:24461)
  at android.view.ViewGroup.layout (ViewGroup.java:7412)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:374)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:312)
  at com.android.internal.policy.DecorView.onLayout (DecorView.java:1331)
  at android.view.View.layout (View.java:24461)
  at android.view.ViewGroup.layout (ViewGroup.java:7412)
  at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:4609)
  at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:4031)
  at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:2919)
  at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:10491)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1108)
  at android.view.Choreographer.doCallbacks (Choreographer.java:866)
  at android.view.Choreographer.doFrame (Choreographer.java:797)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1092)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8669)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:571)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1135)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
 
Upvote 0
Top