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

unbind #8

Open
HahalongGit opened this issue Dec 17, 2016 · 8 comments
Open

unbind #8

HahalongGit opened this issue Dec 17, 2016 · 8 comments

Comments

@HahalongGit
Copy link

unbind无效嘛

@Null8889
Copy link

是的

@AlexLiuSheng
Copy link
Owner

能贴下绑定view的代码?

@Null8889
Copy link

BadgeFactory.create(getActivity())
.setTextColor(Color.WHITE)
.setWidthAndHeight(15, 15)
.setBadgeBackground(Color.RED)
.setTextSize(10)
.setBadgeGravity(Gravity.RIGHT | Gravity.TOP)
.setBadgeCount(msgCount)
.setSpace(4, 4)
.setShape(BadgeView.SHAPE_CIRCLE)
.bind(mTvPushMsg);

@Null8889
Copy link

BadgeFactory.create(getActivity()).unbind(); 这是解绑

@AlexLiuSheng
Copy link
Owner

绑定与解绑的不是同一个对象。
BadgeView badgeView=BadgeFactory.create(getActivity())
.setTextColor(Color.WHITE)
.setWidthAndHeight(15, 15)
.setBadgeBackground(Color.RED)
.setTextSize(10)
.setBadgeGravity(Gravity.RIGHT | Gravity.TOP)
.setBadgeCount(msgCount)
.setSpace(4, 4)
.setShape(BadgeView.SHAPE_CIRCLE)
.bind(mTvPushMsg);
//解绑
badgeView.unbind();

@Null8889
Copy link

改了 一样没效果

@wensonli
Copy link

问题已查明,是BadgeView badgeView=BadgeFactory.create(getActivity())反复调用导致内部framelayout多层嵌套,导致unbind getParent失败。
建议使用时添加判断
private BadgeView badgeView;
private showBadget(TextView textView){
if (badgeView != null ){
badgeView=BadgeFactory.create(getActivity()).bind(textView);
}else {
badgeView.bind(textView);
}
}

private hideBadget(){
if(badgeView != null){
badgeView.unbind();
}
}

@AlexLiuSheng
Copy link
Owner

👍

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

4 participants