【问题标题】:download images with json url in android在android中下载带有json url的图像
【发布时间】:2019-01-15 20:29:15
【问题描述】:

如何用 json 下载这些 url 图片?

这是我的图片 URL,我想下载并显示这些图片。我怎样才能recyclerview?我的模式是什么?如何逐步下载图像?我将这些链接保存在 mysql db 中,并用 json 显示它们,如下所示。我希望我已经能够表达我的意思,我为英语感到抱歉。

这是我的 json 代码:

{
  "images url": [
    {
      "id": "1",
      "url": "http://mehrsoftshop.ir/images/mobile-1.jpg",
      "discount_code": "0",
      "price": "0",
      "details": "",
      "points": "0",
      "is_found": "0"
    },
    {
      "id": "2",
      "url": "http://mehrsoftshop.ir/images/mobile-2.jpg",
      "discount_code": "0",
      "price": "0",
      "details": "",
      "points": "0",
      "is_found": "0"
    },
    {
      "id": "3",
      "url": "http://mehrsoftshop.ir/images/mobile-3.jpg",
      "discount_code": "0",
      "price": "0",
      "details": "",
      "points": "0",
      "is_found": "0"
    },
    {
      "id": "4",
      "url": "http://mehrsoftshop.ir/images/mobile-4.jpg",
      "discount_code": "0",
      "price": "0",
      "details": "",
      "points": "0",
      "is_found": "0"
    },
    {
      "id": "5",
      "url": "http://mehrsoftshop.ir/images/mobile-5.jpg",
      "discount_code": "0",
      "price": "0",
      "details": "",
      "points": "0",
      "is_found": "0"
    },
    {
      "id": "6",
      "url": "http://mehrsoftshop.ir/images/mobile-6.jpg",
      "discount_code": "0",
      "price": "0",
      "details": "",
      "points": "0",
      "is_found": "0"
    },
    {
      "id": "7",
      "url": "http://mehrsoftshop.ir/images/mobile-7.jpg",
      "discount_code": "0",
      "price": "0",
      "details": "",
      "points": "0",
      "is_found": "0"
    },
  ]
}

【问题讨论】:

  • 你知道怎么解析json吗?如果是这样,有一个名为毕加索的图书馆。 square.github.io/picasso 效果很好....如果您需要有关 recycler 视图的帮助,我建议您查看教程并以这种方式获得帮助。归根结底,stackoverflow 可以帮助您编写代码。而不是提供整体解决方案。

标签: android json image android-recyclerview download


【解决方案1】:

使用 Glide 和 Picasso 将图像加载到活动中。

Glide.with(context).load("url").into(imageView);

使用 Retrofit 或 Asynctask 来解析 JSON。创建一个 Recycler 视图并在 Adapter 类的 onBindViewHolder 方法中,尝试此代码。 如需更多参考,请查看此存储库。 Click here

【讨论】:

    猜你喜欢
    • 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
    相关资源
    最近更新 更多