您的位置:首页 > 其它

开源中国(三)

2016-06-18 22:51 405 查看
android:descendantFocusability用法简析

在遇到因ImageButton,Button,CheckBox等子控件(也可以说是Button或者Checkable的子类控件),此时这些子控件会将焦点获取到,而导致item没有获取焦点可设置
android:descendantFocusability=”blocksDescendants”
的属性

消息通知

MianActivity
中设置广播,进行广播监听,广播的总数等于各个消息的总和,判断是不
MyInformationFragment
进行数值传递

private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Constants.INTENT_ACTION_NOTICE)) {
mNotice = (Notice) intent.getSerializableExtra("notice_bean");
int atmeCount = mNotice.getAtmeCount();// @我
int msgCount = mNotice.getMsgCount();// 留言
int reviewCount = mNotice.getReviewCount();// 评论
int newFansCount = mNotice.getNewFansCount();// 新粉丝
int newLikeCount = mNotice.getNewLikeCount();// 收到赞
int activeCount = atmeCount + reviewCount + msgCount
+ newFansCount + newLikeCount;

Fragment fragment = getCurrentFragment();
if (fragment instanceof MyInformationFragment) {
((MyInformationFragment) fragment).setNotice();
} else {
if (activeCount > 0) {
mBvNotice.setText(activeCount + "");
mBvNotice.show();
} else {
mBvNotice.hide();
mNotice = null;
}
}
} else if (intent.getAction()
.equals(Constants.INTENT_ACTION_LOGOUT)) {
mBvNotice.hide();
mNotice = null;
}
}
};


之后通过
BadgeView
对数值展示,小红点的数值

mMesCount = new BadgeView(getActivity(), mMesView);
//设置小红点的大小
mMesCount.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
//设置小红点居中
mMesCount.setBadgePosition(BadgeView.POSITION_CENTER);
mMesCount.setGravity(Gravity.CENTER);
mMesCount.setBackgroundResource(R.drawable.notification_bg);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: