展会信息港展会大全

如何异步加载网络中图片,并缓存到内存和SD卡中
来源:互联网   发布日期:2016-01-14 11:31:39   浏览:1767次  

导读:dependencies { compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3' } public class UIHelper { public static DisplayImageOptions getDisplayImageOptions(Context context) { if (displayImageOptions == null) { Drawable loadi...

dependencies {

compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'

}

public class UIHelper {

public static DisplayImageOptions getDisplayImageOptions(Context context) {

if (displayImageOptions == null) {

Drawable loading = context.getResources().getDrawable(R.drawable.loading);

displayImageOptions = new DisplayImageOptions.Builder()

.showImageOnLoading(loading)

.showImageForEmptyUri(loading)

.showImageOnFail(loading)

.cacheInMemory(true)

.cacheOnDisk(true)

.build();

}

return displayImageOptions;

}

}

private void initView(View view) {

imageViewTouch = (ImageViewTouch) view.findViewById(R.id.thisImage);

ImageLoader.getInstance().displayImage(url, imageViewTouch, UIHelper.getDisplayImageOptions(getActivity()));

}

赞助本站

人工智能实验室

相关热词: android开发 android教程

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港