@Override public View getView(final int position, View convertView, ViewGroup arg2) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.item_events_message, null); holder.tv_message = (TextView) convertView.findViewById(R.id.tv_message); holder.tv_time = (TextView) convertView.findViewById(R.id.tv_time); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } GDMessage msg = list.get(position); // 去掉前面的 // content=来自 跑步群发消息:嘟嘟嘟 String message = msg.getContent().substring(msg.getContent().indexOf(":") + 1); holder.tv_message.setText(message); String time = msg.getCreated_at().trim(); try { holder.tv_time.setText(GDUtil.getTimeDiff2(dwf.parse(time))); } catch (ParseException e1) { e1.printStackTrace(); } return convertView; }
/** 兴趣运动 */ private void setUserSports() { if (!TextUtils.isEmpty(user.getSports())) { ll_sports.removeAllViews(); String[] picNames = user.getSports().split(","); for (int i = 0; i < picNames.length; i++) { if (i < 5) { ImageView imageView = new ImageView(this); imageView.setLayoutParams( new LinearLayout.LayoutParams( (int) (20 * OxygenApplication.ppi), (int) (20 * OxygenApplication.ppi))); imageView.setBackgroundDrawable( GDUtil.engSporttodrawable(this, "icon_index_" + picNames[i].replace(" ", ""))); ll_sports.addView(imageView); } } } }
@Override public View getView(int arg0, View convertView, ViewGroup arg2) { ViewHolder holder = null; if (convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.item_postslist, null); holder.tv_title = (TextView) convertView.findViewById(R.id.tv_title); holder.tv_summary = (TextView) convertView.findViewById(R.id.tv_summary); holder.iv_head = (ImageView) convertView.findViewById(R.id.iv_head); holder.tv_votecount = (TextView) convertView.findViewById(R.id.tv_votecount); holder.tv_readcount = (TextView) convertView.findViewById(R.id.tv_readcount); holder.tv_created_at = (TextView) convertView.findViewById(R.id.tv_created_at); holder.tv_tag = (TextView) convertView.findViewById(R.id.tv_tag); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } Posts posts = postses.get(arg0); ArrayList<PostsTag> posttags = posts.getTags(); if (posttags != null && posttags.size() > 0) { holder.tv_tag.setVisibility(View.VISIBLE); holder.tv_tag.setBackgroundDrawable(GDUtil.engSporttodrawable(c, "icon_tag_" + arg0 % 6)); holder.tv_tag.setText(posttags.get(0).getName()); } else { holder.tv_tag.setVisibility(View.GONE); } holder.tv_created_at.setText(posts.getPublish_time()); holder.tv_readcount.setText("" + posts.getRead_count()); holder.tv_votecount.setText("" + posts.getVote_count()); holder.tv_title.setText(posts.getTitle()); holder.tv_summary.setText(posts.getSummary()); ImageUtil.showImage( posts.getPic() + Constants.qiniu_photo_head, holder.iv_head, R.drawable.icon_def); return convertView; }