[android]代码库public class ListViewAdapter extends BaseAdapter
{
private ArrayList imgs;
private Context mContext;
private LayoutInflater inflater;
private ImageProcessor mImageProcessor;
TextView itemTitleTxt;
public ListViewAdapter(Context con)
{
super();
mContext = con;
imgs = new ArrayList();
inflater = LayoutInflater.from(mContext);
prepareImageProcessor(mContext);
}
private void prepareImageProcessor(Context context)
{
final int thumbnailSize = context.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size);
final int thumbnailRadius = context.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing);
mImageProcessor = new ChainImageProcessor(new ScaleImageProcessor(thumbnailSize, thumbnailSize, ScaleType.FIT_XY), new MaskImageProcessor(thumbnailRadius));
}
public void refersh(ArrayList list)
{
if (imgs != null && list != null && !list.isEmpty())
{
imgs.clear();
imgs.addAll(list);
// 为了制造更多的数据
imgs.addAll(list);
imgs.addAll(list);
imgs.addAll(list);
imgs.addAll(list);
}
[源代码打包下载]