@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder = null; if (convertView == null) { convertView = parent.inflate(mcontext, R.layout.item_recruitment_detail_work, null); viewHolder = new ViewHolder(convertView); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.setData(position); return convertView; }
@Override public void onBindViewHolder(final ViewHolder holder, int position) { String pokemonName = mPokemonList.get(position).getName(); pokemonName = pokemonName.substring(0, 1).toUpperCase().concat(pokemonName.substring(1)); final int pokeNum = position + 1; holder.setData(pokemonName, pokeNum, mContext); holder.itemView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { onPokemonClicked(pokeNum); } }); }
@Override public void onBindViewHolder(ViewHolder viewHolder, final int position) { final int imageResId = mImageResIds[position]; final String name = mNames[position]; final String description = mDescriptions[position]; final String url = mUrls[position]; viewHolder.setData(imageResId, name); viewHolder.itemView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mListener.onRageComicSelected(imageResId, name, description, url); } }); }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.recommond_card, parent, false); holder = new ViewHolder(); holder.title = (TextView) convertView.findViewById(R.id.recommond_card_title); holder.subtitle = (TextView) convertView.findViewById(R.id.recommond_card_subtitle); holder.detail = (TextView) convertView.findViewById(R.id.recommond_card_detail); holder.order = (Button) convertView.findViewById(R.id.recommond_card_order); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // 上面所做的只是将holder用起来 holder.setData(products.get(position)); if (onOrderClickListener != null) holder.setOnOrderClickListener(onOrderClickListener); return convertView; }
@Override public void onViewRecycled(ViewHolder holder) { super.onViewRecycled(holder); holder.setData("", 0, mContext); }
@Override public void onBindViewHolder(ViewHolder holder, int position) { holder.setData(mItems.get(position)); }