问题是我很困惑哪个库更容易使用并且具有更好的性能?
Android查询或Android通用图像加载器(UIL)?
解决方法 Android Universal Image Loader就像一个冠军.它很容易使用here就是一个例子
但是,基本上这是将它与GrIDVIEw一起使用的方法:
在预期的进口之后,你应该:
protected AbsListVIEw List;protected ImageLoader loader = ImageLoader.getInstance();private String query;final Context context = this;private ItemAdapter adapter;private displayImageOptions op;@OverrIDe public voID onCreate(Bundle savedInstanceState) { op = new displayImageOptions.Builder() .displayer(new RoundedBitmapdisplayer(20)) .build(); List = (GrIDVIEw) findVIEwByID(R.ID.grIDVIEwSearch); adapter = new ItemAdapter(images); List.setAdapter(adapter); List.setonItemClickListener(new AdapterVIEw.OnItemClickListener() { @OverrIDe public voID onItemClick(AdapterVIEw<?> parent,VIEw vIEw,int position,long ID) { // Do whatever you need to do after clicking an image. } });}
当然,你需要适配器:
class ItemAdapter extends BaseAdapter { private String[] imagesA; public ItemAdapter(String [] Images){ this.imagesA = Images; } public voID setData(String [] Images){ this.imagesA = Images; } private class VIEwHolder { public ImageVIEw image; } @OverrIDe public int getCount() { return imagesA.length; } @OverrIDe public Object getItem(int position) { return position; } @OverrIDe public long getItemID(int position) { return position; } @OverrIDe public VIEw getVIEw(final int position,VIEw convertVIEw,VIEwGroup parent) { VIEw v = convertVIEw; v = getLayoutInflater().inflate(R.layout.image_in_grIDvIEw_layout,parent,false); final Progressbar spinner = (Progressbar) v.findVIEwByID(R.ID.loading); final VIEwHolder holder = new VIEwHolder(); holder.image = (ImageVIEw) v.findVIEwByID(R.ID.grID_item_image); v.setTag(holder); loader.displayImage(imagesA[position],holder.image,op,new SimpleImageLoadingListener() { @OverrIDe public voID onLoadingStarted(String imageUri,VIEw vIEw) { spinner.setVisibility(VIEw.VISIBLE); } @OverrIDe public voID onLoadingFailed(String imageUri,FailReason failReason) { spinner.setVisibility(VIEw.GONE); } @OverrIDe public voID onLoadingComplete(String imageUri,Bitmap loadedImage) { spinner.setVisibility(VIEw.GONE); } }); return v; }总结
以上是内存溢出为你收集整理的哪个Android图片库用于在线照片加载全部内容,希望文章能够帮你解决哪个Android图片库用于在线照片加载所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)