SHSwipeRefreshLayout icon indicating copy to clipboard operation
SHSwipeRefreshLayout copied to clipboard

viewpager+recyclerview 出现bug

Open liangzhengang opened this issue 8 years ago • 0 comments

The specified child already has a parent. You must call removeView() on the child's parent first.

at com.scu.miomin.shswiperefresh.core.SHSwipeRefreshLayout.setGuidanceView(SHSwipeRefreshLayout.java:217) at com.scu.miomin.shswiperefresh.core.SHSwipeRefreshLayout.onAttachedToWindow(SHSwipeRefreshLayout.java:202) 我用途是一个tablayout+viewpager+recyclerview 做的联动下拉刷新,在viewpager二次滑动时(既首次滑动某到某viewpager是没问题,例如从pager1滑动到pager2,pager2滑动到pager1),会出现这个问题。 因为首次滑动正常排除了我布局的问题,感觉是不是说在销毁的时候,没有移除父view;; private void setGuidanceView() { // SetUp HeaderView LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, 0); if (headerView.getParent()==null) { headerView.setStartEndTrim(0, 0.75f); headerView.setText(mRefreshDefaulText); headerView.setTextColor(mGuidanceViewTextColor); headerView.setBackgroundColor(mGuidanceViewBgColor); headerView.setProgressBgColor(mProgressBgColor); headerView.setProgressColor(mProgressColor); addView(headerView, lp); }

    // SetUp FooterView
    if (footerView.getParent()==null)
    {
        lp = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
        lp.gravity = Gravity.BOTTOM;
        footerView.setStartEndTrim(0.5f, 1.25f);
        footerView.setText(mLoadDefaulText);
        footerView.setTextColor(mGuidanceViewTextColor);
        footerView.setBackgroundColor(mGuidanceViewBgColor);
        footerView.setProgressBgColor(mProgressBgColor);
        footerView.setProgressColor(mProgressColor);
        addView(footerView, lp);
    }

}

liangzhengang avatar Sep 06 '17 09:09 liangzhengang