Listview点击已读使用getBadgeView标示

重:每个ListItem是属于ListItem自己的,不能够放到ViewHolder中,而是数据源每项的.
 @Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.inbox_list_item, parent, false);
holder = new ViewHolder(convertView);
} else {
holder = (ViewHolder) convertView.getTag();
} ReceiveBoxResponse.ListBean bean = list.get(position);
holder.from_username.setText(bean.getFrom_username());
holder.content.setText(bean.getTitle());
holder.time.setText(bean.getCreate_time()); //是否已读
Object tag=holder.time.getTag();
if (tag == null) {
QBadgeView qBadgeView=new QBadgeView(parent.getContext());//
qBadgeView.bindTarget(holder.overlay_badge);
qBadgeView.setBadgeGravity(Gravity.START | Gravity.TOP);
if("".equals(bean.getHas_read())) {
qBadgeView.setBadgeNumber();////1:已读,0:未读
}else {
qBadgeView.setBadgeNumber();
} holder.time.setTag(qBadgeView);
}else{
QBadgeView qQBadgeView=(QBadgeView)tag;
if("".equals(bean.getHas_read())) {
qQBadgeView.setBadgeNumber();////1:已读,0:未读
}else {
qQBadgeView.setBadgeNumber();
}
} if(mStateIsEdit){
holder.check_box.setVisibility(View.VISIBLE);
if(bean.isState()){
holder.check_box.setChecked(true);
}else{
holder.check_box.setChecked(false);
}
}else{
holder.check_box.setVisibility(View.GONE);
}
return convertView;
}
上一篇:[Lua]50行代码的解释器,用来演示lambda calculus


下一篇:C语言创建及解析Json的使用法则