繁体   English   中英

无法使用Picasso库在android中加载图像

[英]unable to load image in android using picasso library

希望你做的很好,我正在开发一个应用程序,因为我想将URL中的图像加载到imageView中,我为此使用了Picasso lib,但它给了我未捕获的异常,我已经检查并调试了是否合适?网址是来还是不来和它完美的,不过我面对这个问题,任何人可以帮助我解决这个我的代码如下: 代码

Picasso.with(NewProfileActivity.this)
                        .load(mUser.userAvatarPath)
                        .into(iv_profile);

此处,“ iv_profile”是imageView,mUser.userAvatar路径是图像url。

尝试这个

Picasso.with(this).load("http://api.androidhive.info/json/movies/1.jpg").placeholder(getResources().getDrawable(R.drawable.ic_launcher)).into(imageViewCenter);
Picasso.with(this).load("http://city/1.jpg").placeholder(getResources().getDrawable(R.drawable.ic_city)).into(imageViewCity);

尝试这个,

Picasso.with(context)
.load(url)
.placeholder(R.drawable.user_placeholder)
.error(R.drawable.user_placeholder_error)
.into(imageView);

未加载原始网址时, 占位符会有所帮助。

并把

 <uses-permission android:name="android.permission.INTERNET" />

到您的manifest.xml

这可能对您有帮助。

请检查您的图片网址,如果其中不含http://前缀,则不会加载图片。 确保图片URL带有http://前缀

在您的情况下使用此代码工作

Picasso.with(mContext).load(Imagename.png).fit().centerCrop().error(R.mipmap.ic_profile).fit().placeholder(R.mipmap.ic_profile).fit().into(imgNDProfile);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM