Пример #1
0
  @SuppressLint("InflateParams")
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      convertView = LayoutInflater.from(context).inflate(R.layout.user_item, null);
      ItemViewCache itemViewCache = new ItemViewCache();
      itemViewCache.imageViewUser = (ImageView) convertView.findViewById(R.id.imageViewUser);
      itemViewCache.textViewUser = (TextView) convertView.findViewById(R.id.textViewUser);
      itemViewCache.textViewCount = (TextView) convertView.findViewById(R.id.textViewCount);
      itemViewCache.textViewDate = (TextView) convertView.findViewById(R.id.textViewDate);
      convertView.setTag(itemViewCache);
    }

    ItemViewCache cache = (ItemViewCache) convertView.getTag();
    User user = userList.get(position);
    URL url = user.getUserAvatar();
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(128, 128);
    layoutParams.leftMargin = 5;
    layoutParams.rightMargin = 5;
    layoutParams.topMargin = 5;
    layoutParams.bottomMargin = 5;
    cache.imageViewUser.setLayoutParams(layoutParams);
    if (url != null) {
      imageLoader.displayImage(url.toString(), cache.imageViewUser);
    }

    cache.textViewUser.setText(user.getTitle());
    cache.textViewCount.setText("随笔总数:" + user.getPostCount());
    cache.textViewDate.setText("最后更新:" + AppUtils.parseDateToString(user.getUpdatedDate()));

    return convertView;
  }
Пример #2
0
  public View getView(int position, View convertView, ViewGroup parent) {
    // use cache for optimize
    if (convertView == null) {
      convertView = LayoutInflater.from(mContext).inflate(R.layout.order_item, null);
      ItemViewCache viewCache = new ItemViewCache();
      viewCache.name = (TextView) convertView.findViewById(R.id.shop_name);
      viewCache.time = (TextView) convertView.findViewById(R.id.time);
      viewCache.shortDesc = (TextView) convertView.findViewById(R.id.status);
      viewCache.longDesc = (TextView) convertView.findViewById(R.id.status_desc);
      viewCache.price = (TextView) convertView.findViewById(R.id.price);
      convertView.setTag(viewCache);
    }
    ItemViewCache cache = (ItemViewCache) convertView.getTag();

    cache.name.setText(orders.get(position).getShopName());
    cache.time.setText(orders.get(position).getStringTime());
    cache.price.setText(orders.get(position).getPrice() + "");
    cache.shortDesc.setText(GlobalSettings.getStatusShortDesc(orders.get(position).getStatus()));
    cache.longDesc.setText(GlobalSettings.getStatusLongDesc(orders.get(position).getStatus()));
    return convertView;
  }