3

I have a RecyclerView in a LinearLayout, which also contains an EditText.

The container Activity has android:windowSoftInputMode="adjustResize|stateHidden" set - so when the soft input opens, the RecyclerView shrinks because it's space has been readjusted.

Unfortunately, when you click the EditText causing the soft input to open, the following exception is thrown. I'm assuming this is another bug with the Android Support Library - can anyone confirm and perhaps suggest a work around?

    java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true
        at android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:4570)
        at android.support.v7.widget.RecyclerView$Recycler.quickRecycleScrapView(RecyclerView.java:4642)
        at android.support.v7.widget.RecyclerView$LayoutManager.removeAndRecycleScrapInt(RecyclerView.java:6636)
        at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2811)
        at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3011)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:581)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:514)

Edit

I spent the last several hours slowly deconstructing my project, until the problem went away. I then reversed by changes after lunch. In a fit of insanity inducing madness, reversing the changes hasn't reintroduced the bug.

I am still 100% snookered by what this bug is, I begin to worry either I'm mad or there is an intermittent cause to this bug which has temporarily gone away :(

Bugs Happen
  • 2,169
  • 4
  • 33
  • 59
Graeme
  • 25,714
  • 24
  • 124
  • 186
  • 1
    Check this.. http://stackoverflow.com/questions/26477660/recyclerview-crashes-when-scrapped-or-attached-views-may-not-be-recycled – Anitha Manikandan Aug 27 '15 at 11:09
  • Yes, seen it, not related to this issue. Thanks for posting though. I'm not using any item animation, `android:animateLayoutChanges` has not been set and `android:focusableInTouchMode="true"` had no effect (and I have no idea why it should) – Graeme Aug 27 '15 at 11:10
  • How about this one http://stackoverflow.com/a/40799494/1708390 ? I was facing the same issue and I think this resolved my problem – Bugs Happen Dec 29 '16 at 05:49

0 Answers0