qyxxjd / MultipleStatusView

一个支持多种状态的自定义View,可以方便的切换到:加载中视图、错误视图、空数据视图、网络异常视图、内容视图。
MIT License
1.69k stars 243 forks source link

然后在fragment应用 外层是viewpager+tablayout 滑动几次就会空白 #41

Open printlybyte opened 4 years ago

printlybyte commented 4 years ago

MultipleStatusView 嵌套TwinklingRefreshLayout

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white">

<com.classic.common.MultipleStatusView
    android:id="@+id/include_multiple_status_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:emptyView="@layout/custom_empty_view"
    app:errorView="@layout/custom_error_view"
    app:loadingView="@layout/custom_loading_view"
    app:noNetworkView="@layout/custom_no_network_view"

    >

    <!--scrollview布局-->
    <com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout
        android:id="@+id/include_refreshLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <!--列表布局-->
        <android.support.v7.widget.RecyclerView
            android:id="@+id/include_recyclerview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/headview"
            android:background="#fff"
            android:focusableInTouchMode="false"
            android:overScrollMode="never"
            android:scrollbars="none" />

    </com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout>
</com.classic.common.MultipleStatusView>

然后在fragment应用 外层是viewpager+tablayout 滑动几次就会空白

Anima18 commented 4 years ago

遇到同样问题,层主解决了吗

Anima18 commented 4 years ago

问题解决了,看了源码,在onDetachedFromWindow做了清除视图工作,把这段代码注销掉就可以了


    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        /*clear(mEmptyView, mLoadingView, mErrorView, mNoNetworkView);
        if (!mOtherIds.isEmpty()) {
            mOtherIds.clear();
        }
        if (null != mOnRetryClickListener) {
            mOnRetryClickListener = null;
        }
        if (null != mViewStatusListener) {
            mViewStatusListener = null;
        }*/
    }```
@printlybyte