通过毕加索库通过图像网址在安卓新设备中的图像加载问题



应用程序在Android旧版本中运行,图像显示完美,但是当它在较新的Android版本中运行时,它在imageview部分中显示为空白。 我用过毕加索。

字符串 image_url = "http://***.com/uploads/user_photo/" + imagelist.get(position(.getUser_photo((;

Picasso.with(context)
.load(image_url )
.into(holder.imgView);

我想你的意思是它不适用于Android 9+,但在Android <= 8上可以正常工作。 可能是这种情况,因为您尝试加载的图像网址使用 http。Android 9+ 默认阻止 http,只接受 https 网址。

查看此答案,了解有关如何在 Android 9+ 上为您的应用程序启用 http 的详细信息。 如何在Android (9( Pie中允许所有网络连接类型HTTP和HTTPS?

请记住,测试时很好,但您不应该在生产应用程序上启用 http,他们禁用它是有原因的。

使用Picasso.get().load("image_url").into(holder.imgView);

试试这个

Picasso.with(context)  // Activity context
.load("https:URL") // Set URL
.resize(100,100) // you also Resize the image
.placeholder(getResources().getDrawable(R.drawable.waterMark)) // Default Image
.error(getResources().getDrawable(R.drawable.errorImg)) // if errors occurs
.into(holder.heroesImage); // Your Imageview

并确保您的网址是HTTPS

最新更新