これは私BaseAdapater
が使用している私のクラスですViewHolder
。
public class CategoryAdapter extends BaseAdapter {
private Context mContext;
public int[] mThumbIds = {R.drawable.shoes,R.drawable.dress,R.drawable.purse,
R.drawable.shoes,R.drawable.dress,R.drawable.purse ,
R.drawable.shoes,R.drawable.dress,R.drawable.purse };
public WishbookCategoryAdapter(Context c){
mContext = c;
}
@Override
public int getCount() {
return mThumbIds.length;
}
@Override
public Object getItem(int position) {
return mThumbIds[position];
}
@Override
public long getItemId(int position) {
return (long)position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if(convertView==null){
holder = new ViewHolder();
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = li.inflate(R.layout.wishbook_gridview_items, null);
holder.Category = (TextView)convertView.findViewById(R.id.wishbook_grid_category);
holder.items = (TextView)convertView.findViewById(R.id.wishbook_grid_category_number);
holder.iv = (ImageView)convertView.findViewById(R.id.wishbook_category_image);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder)convertView.getTag();
}
holder.iv.setImageDrawable(mContext.getResources().getDrawable(mThumbIds[position]));
holder.iv.setScaleType(ScaleType.FIT_XY);
holder.Category.setText("Category");
holder.items.setText("items");
return convertView;
}
private static class ViewHolder {
protected ImageView iv;
protected TextView Category;
protected TextView items;
}
}