【问题标题】:unable to load image in android using picasso library无法使用毕加索库在android中加载图像
【发布时间】:2016-09-03 19:22:34
【问题描述】:

希望你做得很好,我正在开发一个应用程序,因为我想将图像从 url 加载到 imageView,为此我使用了 Picasso lib,但它给了我未捕获的异常,我已经检查和调试因为是正确的 url 来还是不完美,我仍然面临这个问题,有人可以帮我解决这个问题吗?我的代码如下: 代码

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

这里,“iv_profile”是imageView,mUser.userAvatar Path是图片url。

【问题讨论】:

标签: android url imageview picasso image-loading


【解决方案1】:

试试这个

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

【讨论】:

    【解决方案2】:
    Picasso.with(this).load("http://city/1.jpg").placeholder(getResources().getDrawable(R.drawable.ic_city)).into(imageViewCity);
    

    【讨论】:

      【解决方案3】:

      请检查您的图片 URL,如果它不包含 http:// 前缀,则不会加载图片。确保图像 URL 以 http://

      为前缀

      【讨论】:

        【解决方案4】:

        试试这个,

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

        placeholder 在您的原始网址未加载时提供帮助。

        然后放

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

        到你的 manifest.xml

        这可能会对你有所帮助。

        【讨论】:

          【解决方案5】:

          在您的情况下使用此代码

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

          【讨论】:

          • 可能是您的代码中的错误,在其他地方找到它,可能是您的图像名称有大写字母或其他问题检查我们的代码 Man..
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多