@Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; RecordHolder holder = null; if (row == null) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); holder = new RecordHolder(); holder.txtTitle = (TextView) row.findViewById(R.id.item_text); holder.imageItem = (ImageView) row.findViewById(R.id.item_image); holder.txtCount = (TextView) row.findViewById(R.id.item_count); row.setTag(holder); } else { holder = (RecordHolder) row.getTag(); } if (position >= data.size()) return row; // fix bug UserModel item = data.get(position); holder.txtTitle.setText(item.getName()); holder.postion = position; if (holder.txtCount != null) holder.txtCount.setText(String.valueOf(item.getCountFootprint())); // holder.imageItem.setImageDrawable(context.getResources().getDrawable(R.drawable.loader)); imageFetcher.loadImage(item.getUserAvatar(), holder.imageItem); // getImgFromSDCard(holder, item, position); return row; }
public CustomGridViewAdapter(Context context, int layoutResourceId, Vector<UserModel> data) { super(context, layoutResourceId, data); this.layoutResourceId = layoutResourceId; this.context = context; this.data = data; imageFetcher = MyApplication.getInstance().getImageFetcher(); // imageFetcher.setImageFadeIn(true); imageFetcher.setLoadingImage(R.drawable.loader); }