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

viewpager+recyclerview 出现bug #17

Open
liangzhengang opened this issue Sep 6, 2017 · 0 comments
Open

viewpager+recyclerview 出现bug #17

liangzhengang opened this issue Sep 6, 2017 · 0 comments

Comments

@liangzhengang
Copy link

liangzhengang commented Sep 6, 2017

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

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

No branches or pull requests

1 participant