BadgeView icon indicating copy to clipboard operation
BadgeView copied to clipboard

unbind

Open HahalongGit opened this issue 8 years ago • 8 comments

unbind无效嘛

HahalongGit avatar Dec 17 '16 06:12 HahalongGit

是的

Null8889 avatar Mar 27 '17 11:03 Null8889

能贴下绑定view的代码?

AlexLiuSheng avatar Mar 27 '17 11:03 AlexLiuSheng

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 avatar Mar 27 '17 11:03 Null8889

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

Null8889 avatar Mar 27 '17 11:03 Null8889

绑定与解绑的不是同一个对象。 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();

AlexLiuSheng avatar Mar 27 '17 11:03 AlexLiuSheng

改了 一样没效果

Null8889 avatar Mar 28 '17 03:03 Null8889

问题已查明,是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(); } }

wensonli avatar Aug 28 '17 07:08 wensonli

👍

AlexLiuSheng avatar Aug 30 '17 02:08 AlexLiuSheng