【发布时间】:2016-05-16 07:18:53
【问题描述】:
我有这个从 url 加载图像的工作功能。唯一的问题是它在加载图像时没有显示任何进展,只是屏幕变暗,一段时间后只显示图片。这使用户认为它不起作用。那么如何在图像加载时添加进度对话框或以任何方式显示图像正在加载?
public void showImage() {
Dialog builder = new Dialog(this);
builder.requestWindowFeature(Window.FEATURE_NO_TITLE);
builder.getWindow().setBackgroundDrawable(
new ColorDrawable(android.graphics.Color.TRANSPARENT));
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
//nothing;
}
});
ImageView imageView = new ImageView(this);
Picasso.with(this).load("http://camranger.com/wp-content/uploads/2014/10/Android-Icon.png").into(imageView);
builder.addContentView(imageView, new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
builder.show();
}
【问题讨论】:
-
.into()方法有第二个参数作为回调来检查图像是否已加载。你试过了吗?