在 Picasso 库中,当我的图像被加载时,我现在如何触发哪个事件侦听器?

ama*_*rma 2 android picasso

大家好,我在 android 项目中使用毕加索,现在我的问题是我需要在毕加索正在加载的图像上显示一些内容,这就是为什么我想知道我如何知道毕加索何时加载了图像,因为只有这样我才能在该图像上添加文本。此外,如果 picasso 不提供此功能,那么在 android 中使用 picassso 是否还有其他方法可以做到这一点

Picasso.with(context).load("http://192.168.0.15:1337/offers/" + image_url.get(position)).resize(350, 100).centerCrop().into(holder.imageView);
Run Code Online (Sandbox Code Playgroud)

现在在哪里设置图像上的文本。

Par*_*ani 5

您可以在请求中包含回调参数。在图像加载成功或错误响应上做任何你想做的事情。

Picasso.with(getContext())
    .load(url)
    .into(imageView, new com.squareup.picasso.Callback() {
                        @Override
                        public void onSuccess() {

                        }

                        @Override
                        public void onError() {

                        }
                    });
Run Code Online (Sandbox Code Playgroud)