@Override public void onBindViewHolder(ViewHolder holder, int position) { switch (getItemViewType(position)) { case TYPE_HEADER: holder.update(position); break; default: // TYPE_REPLY holder.update(position - 1); break; } }
// Replace the contents of a view (invoked by the layout manager) @Override public void onBindViewHolder(ViewHolder holder, int position) { // - get element from the dataset at this position // - replace the contents of the view with that element AddressBookItem address = addresses.get(position); holder.update(address); }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.study_record_list_item, null); holder = new ViewHolder(convertView); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.update(list.get(position), position); return convertView; }
@Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = inflater.inflate(R.layout.task_list_item, null); holder = new ViewHolder(getItem(position), convertView); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.update(getItem(position)); return convertView; }
@Override public void onBindViewHolder(ViewHolder holder, int position) { holder.update(position); }