Skip to content

viewpager+recyclerview 出现bug #17

Open
@liangzhengang

Description

@liangzhengang

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);
    }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions