如何显示错误消息

如何显示错误消息

本文介绍了Android:Picasso加载图片失败。如何显示错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用picasso库在mediastore中加载图像存储。当我调用load(imageview,callback)时,毕加索调用onFail而不是onSuccess。我如何知道图像未成功加载的原因?

I am trying to use the picasso library to loading the image store in the mediastore. When I called load(imageview, callback), the picasso call onFail instead of onSuccess. How do I know why the image was not loaded successfully?

推荐答案

使用构建器:

    Picasso.Builder builder = new Picasso.Builder(this);
    builder.listener(new Picasso.Listener()
    {
        @Override
        public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception)
        {
            exception.printStackTrace();
        }
    });
    builder.build().load(URL).into(imageView);

修改

对于版本2.71828,他们为onError回调添加了异常:

For version 2.71828 they have added the exception to the onError callback:

        Picasso.get()
            .load("yoururlhere")
            .into(imageView, new Callback() {
                @Override
                public void onSuccess() {
                }

                @Override
                public void onError(Exception e) {
                }
            })

这篇关于Android:Picasso加载图片失败。如何显示错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 13:35