Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrapped or attached views may not be recycled. isScrap:false isAttached:true #320

Closed
duongnv1996 opened this issue Dec 19, 2017 · 10 comments

Comments

@duongnv1996
Copy link

Hi , I got some crash when my list have one or two item then I pull down to refresh.
Here is message :
FATAL EXCEPTION: main Process: com.portalbeanz.chezzypizza, PID: 31417 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:5736) at android.support.v7.widget.RecyclerView$Recycler.quickRecycleScrapView(RecyclerView.java:5843) at android.support.v7.widget.RecyclerView$LayoutManager.removeAndRecycleScrapInt(RecyclerView.java:8501) at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3656) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3323) at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3844) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586) at android.widget.LinearLayout.onLayout(LinearLayout.java:1495) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586) at android.widget.LinearLayout.onLayout(LinearLayout.java:1495) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336) at android.widget.FrameLayout.onLayout(FrameLayout.java:273) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586) at android.widget.LinearLayout.onLayout(LinearLayout.java:1495) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336) at android.widget.FrameLayout.onLayout(FrameLayout.java:273) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586) at android.widget.LinearLayout.onLayout(LinearLayout.java:1495) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336) at android.widget.FrameLayout.onLayout(FrameLayout.java:273) at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858) at android.view.Choreographer.doCallbacks(Choreographer.java:670) at android.view.Choreographer.doFrame(Choreographer.java:606) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

@duongnv1996 duongnv1996 changed the title Refresh crash when page one have a few item Scrapped or attached views may not be recycled. isScrap:false isAttached:true Dec 19, 2017
@af913337456
Copy link
Member

is it always happen or has a chance

@duongnv1996
Copy link
Author

It happen when list have one item. If we pull down to refresh it's crash

@af913337456
Copy link
Member

i will try and fix it

@duongnv1996
Copy link
Author

Really Thank for that. It's awesome android library

@af913337456
Copy link
Member

@duongnv1996 i have tried,but this exception never happen so far,send your code file to my email so i can see it,913337456@qq.com @duongnv1996

@duongnv1996
Copy link
Author

I have sent you email. Check it out please!

@duongnv1996
Copy link
Author

duongnv1996 commented Jan 2, 2018

I got some code layout item.
If I set width , height layout root carview is match_parent , the error will disappear. But if I set width is match_parent and height is wrap_content , the error will come back. I dont know why, I wanna set height is wrap_content .

Here is code :
`

<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">

    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:ignore="MissingPrefix"
        android:orientation="vertical">
        <!--title-->
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:padding="@dimen/dp10">

            <TextView
                android:id="@+id/tv_id_order"
                fontPath="fonts/Muli-Bold.ttf"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/dp5"
                android:gravity="center"
                android:textColor="@color/colorTextDark"
                android:textSize="@dimen/dps20"
                android:textStyle="bold"
                />


            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:orientation="horizontal">

                <TextView
                    fontPath="fonts/Muli-Bold.ttf"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_gravity="top"
                    android:gravity="top"
                    android:text="$"
                    android:textColor="@color/colorTextDark"
                    android:textSize="@dimen/dps14"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/tv_cost_order"
                    fontPath="fonts/Muli-Bold.ttf"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingRight="@dimen/dp10"
                    android:textColor="@color/colorTextDark"
                    android:textSize="@dimen/dps20"
                    android:textStyle="bold" />
            </LinearLayout>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <View
                style="@style/Div_Horizontal"
                android:layout_centerInParent="true" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="@dimen/dp10"
                android:orientation="horizontal"
                android:paddingRight="@dimen/dp10">

                <TextView
                    android:id="@+id/tv_type_cost_order"
                    style="@style/TextStyleCash"
                    android:layout_toLeftOf="@+id/tv_status"
                    android:text="Cash" />

                <TextView
                    android:id="@+id/tv_status"
                    style="@style/TextStyleCash"
                    android:background="@drawable/bg_rounder_green"
                    android:text="New" />
            </LinearLayout>

        </RelativeLayout>

        <!--detail order-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:orientation="vertical"
            android:paddingBottom="@dimen/dp10"
            android:paddingLeft="@dimen/dp15"
            android:paddingRight="@dimen/dp10"
            android:paddingTop="@dimen/dp5">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/tv_title_header_nav"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="order details"
                    android:textAllCaps="true"
                    android:textColor="@color/colorTextDark"
                    android:textSize="@dimen/dps14" />


            </LinearLayout>

            <TextView
                android:id="@+id/tv_name_order"
                style="@style/TextStyle_Header"
                android:layout_marginTop="@dimen/dp2"
               />

            <TextView
                android:id="@+id/tv_phone_order"
                style="@style/TextStyle_Header"
                android:layout_marginBottom="@dimen/dp2"
                android:layout_marginTop="@dimen/dp2"
                android:drawableLeft="@drawable/phone"
                />

            <TextView
                android:id="@+id/tv_address_order"
                style="@style/TextStyle_Header"
                android:drawableLeft="@drawable/locationxxxhdpi"
               />


        </LinearLayout>

        <!--footer-->
        <RelativeLayout
            android:id="@+id/layout_footer_order"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:layout_marginTop="@dimen/dp5"
            android:layout_marginBottom="@dimen/dp15">


            <View
                style="@style/Div_Horizontal"
                android:layout_centerInParent="true" />

            <TextView
                android:id="@+id/btn_change_status_order"
                style="@style/Button_UpdateStatus"
                android:layout_centerVertical="true"
                android:layout_marginLeft="@dimen/dp15"
                android:text="Accept" />

            <TextView
                android:id="@+id/tv_accepted_by_order"
                style="@style/TextStyleCash"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="@dimen/dp15"
                android:background="@drawable/bg_rounder_gray"
                android:text="Accepted by DuongKK"
                android:textColor="@color/white"
                android:visibility="gone" />
        </RelativeLayout>

    </LinearLayout>
</android.support.v7.widget.CardView>

`

@zhenalexfan
Copy link

I am meeting with this problem too. Did you work it out?

@lu79931748
Copy link

after clear listData you should invoke notifyDataSetChanged() method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants