/** 兴趣运动 */ 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; }