@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { convertView = mLayoutInflater.inflate(LAYOUT, null); viewHolder = new ViewHolder(); viewHolder.title = (TextView) convertView.findViewById(R.id.title); viewHolder.poster = (ImageView) convertView.findViewById(R.id.poster); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } // set text properties immediately Movie item = getItem(position); viewHolder.title.setText(item.title); if (item.poster_path != null) { // TODO get image path from TMDb, not static String posterPath = "http://cf2.imgobject.com/t/p/w185" + item.poster_path; mImageDownloader.download(posterPath, viewHolder.poster, false); } return convertView; }
public TmdbMoviesAdapter(Context context) { super(context, LAYOUT); mLayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mImageDownloader = ImageDownloader.getInstance(context); }