【问题标题】:Loading images in recyclerview with picasso from api使用api中的毕加索在recyclerview中加载图像
【发布时间】:2020-02-06 23:15:59
【问题描述】:

使用 picasso 从 api 在 RecyclerView 中添加图像

【问题讨论】:

  • 添加您的代码,到目前为止您已完成,我们将指导您。
  • 告诉我你尝试了什么,我们可以从那里指导你。
  • 第 1 步:谷歌搜索
  • Load Image from Picaso的可能重复

标签: android picasso


【解决方案1】:

使用 Picasso 加载图像非常简单,您可以像这样Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView); 并在他们的website 中获取所有细节。在您的情况下,您可以解析每个图像 URL 并使用 RecyclerView 将它们与毕加索一起显示。

【讨论】:

    【解决方案2】:
    Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView)
    

    在毕加索的新版本中,您不再需要上下文。 我正在使用:

    implementation 'com.squareup.picasso:picasso:2.71828'
    

    【讨论】:

      【解决方案3】:

      在新版毕加索使用get() 毕加索最新版本毕加索库:2.71828

      Picasso
      .get()
      .load("You Img Path Place Here")
      .resize(width, height)
      .noFade()
      .into("Path set ImageView");
      

      使用最新的毕加索版本

       实施 'com.squareup.picasso:picasso:2.71828'

      【讨论】:

      • 根据新的依赖,它是正确的实现。
      【解决方案4】:

      试试这个

      String img_url = "YOUR IMAGE URL";
          if (!img_url.equalsIgnoreCase(""))
              Picasso.with(context).load(img_url).placeholder(R.drawable.user_image)// Place holder image from drawable folder
             .error(R.drawable.user_image).resize(110, 110).centerCrop()
             .into("IMAGE VIEW ID WHERE YOU WANT TO SET IMAGE");
      

      编码愉快。

      【讨论】:

        【解决方案5】:

        你可以像这样使用毕加索加载图片

        Picasso.with(context).load(android_versions.get(i).getAndroid_image_url()).resize(120, 60).into(viewHolder.img_android);
        

        https://www.learn2crack.com/2016/02/image-loading-recyclerview-picasso.html

        【讨论】:

          【解决方案6】:

          这里 ctx 是上下文,list.getImage_full_path()) 是来自服务器的图像,如果未加载图像,则会在占位符中放置静态图像,错误时 kent 是图像名称,into(servicecart_image) 放置在 XML 中,因此图像被加载在那里

           Picasso.with(ctx).load(list.getImage_full_path()).resize(160, 200).placeholder(R.drawable.kent)
                          .error(R.drawable.kent).into(servicecart_image);
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2020-11-14
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多