示例#1
0
  @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;
  }
 /** 设置用户的信息 */
 private void setUserInfo() {
   tv_name.setText(nickname);
   ImageUtil.showImage(headImgUrl, user_headimg, R.drawable.icon_default_head);
   if ("1".equals(sex)) {
     user_sex.setBackgroundResource(R.drawable.user_sex_man);
   } else if ("2".equals(sex)) {
     user_sex.setBackgroundResource(R.drawable.user_sex_woman);
   }
   user_age.setText(age);
   user_friends_count.setText("( " + friendCounts + " )");
   user_group_count.setText("( " + groupCounts + " )");
   add_event_count.setText(eventCounts + "");
   tv_level.setText("LV" + user.getLevel());
   tv_coin.setText("  " + user.getCoins() + "  ");
   int hourIndex = 0;
   int minuteIndex = 0;
   if (duration.contains("小时")) {
     hourIndex = duration.indexOf("小时");
     sport_time_hour.setText(duration.substring(0, hourIndex));
     minuteIndex = duration.indexOf("分钟");
     if (minuteIndex != -1) {
       sport_time_minute.setText(duration.substring(hourIndex + 2, minuteIndex));
     } else {
       sport_time_minute.setText("0");
     }
   } else if (duration.contains("分钟")) {
     minuteIndex = duration.indexOf("分钟");
     sport_time_hour.setText("0");
     sport_time_minute.setText(duration.substring(0, minuteIndex));
   } else {
     sport_time_hour.setText("0");
     sport_time_minute.setText("0");
   }
   tv_calorie.setText(calorie.replace("大卡", ""));
   setUserSports();
 }