【问题标题】:Image loading From java server to android Listview图像加载从 java 服务器到 android Listview
【发布时间】:2015-11-25 06:17:09
【问题描述】:

我正在开发一个安卓应用程序。我需要将图像从 java 服务器加载到 Android Recyclerview 或 Listview。

我通过这个线程 http://www.androidhive.info/2014/06/android-facebook-like-custom-listview-feed-using-volley/ 了解了 android 方面的内容。

我需要 Java 服务器端的帮助。我需要通过 JSON 数组检索图像。像这样

 {
    "feed": [
    {
        "id": 1,
        "name": "National Geographic Channel",
        "image": "http://api.androidhive.info/feed/img/cosmos.jpg",
        "status": "\"Science is a beautiful and emotional human endeavor,\" says Brannon Braga, executive producer and director. \"And Cosmos is all about making science an experience.\"",
        "profilePic": "http://api.androidhive.info/feed/img/nat.jpg",
        "timeStamp": "1403375851930",
        "url": null
    },
    {
        "id": 2,
        "name": "TIME",
        "image": "http://api.androidhive.info/feed/img/time_best.jpg",
        "status": "30 years of Cirque du Soleil's best photos",
        "profilePic": "http://api.androidhive.info/feed/img/time.png",
        "timeStamp": "1403375851930",
        "url": "http://ti.me/1qW8MLB"
    },
    {
        "id": 5,
        "name": "Abraham Lincoln",
        "image": null,
        "status": "That some achieve great success, is proof to all that others can achieve it as well",
        "profilePic": "http://api.androidhive.info/feed/img/lincoln.jpg",
        "timeStamp": "1403375851930",
        "url": null
    },
    {
        "id": 3,
        "name": "Discovery",
        "image": "http://api.androidhive.info/feed/img/discovery_mos.jpg",
        "status": "A team of Austrian scientists has developed a laser system that causes fruit flies to dance.",
        "profilePic": "http://api.androidhive.info/feed/img/discovery.jpg",
        "timeStamp": "1403375851930",
        "url": "http://dsc.tv/xmMxD"
    },
    {
        "id": 4,
        "name": "Ravi Tamada",
        "image": "http://api.androidhive.info/feed/img/nav_drawer.jpg",
        "status": "Android Sliding Menu using Navigation Drawer",
        "profilePic": "http://api.androidhive.info/feed/img/ravi_tamada.jpg",
        "timeStamp": "1403375851930",
        "url": "http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/"
    },
    {
        "id": 6,
        "name": "KTM",
        "image": "http://api.androidhive.info/feed/img/ktm_1290.jpg",
        "status": "\"The Beast\" KTM 1290 Super Duke",
        "profilePic": "http://api.androidhive.info/feed/img/ktm.png",
        "timeStamp": "1403375851930",
        "url": ""
    },
    {
        "id": 7,
        "name": "Harley-Davidson",
        "image": "http://api.androidhive.info/feed/img/harley_bike.jpg",
        "status": "We’re assembling riders of every style, bike, and passion. If you ride with conviction, ride with us. You have 24 days to get ready for World Ride. Prepare by visiting:",
        "profilePic": "http://api.androidhive.info/feed/img/harley.jpg",
        "timeStamp": "1403375851930",
        "url": "http://bit.ly/1wmBWaN"
    },
    {
        "id": 8,
        "name": "Rock & Girl",
        "image": "http://api.androidhive.info/feed/img/rock.jpg",
        "status": "A long time back...",
        "profilePic": "http://api.androidhive.info/feed/img/rock_girl.jpg",
        "timeStamp": "1403375851930",
        "url": ""
    },
    {
        "id": 8,
        "name": "Gandhi",
        "image": null,
        "status": "An eye for an eye will make the whole world blind.",
        "profilePic": "http://api.androidhive.info/feed/img/gandhi.jpg",
        "timeStamp": "1403375851930",
        "url": ""
    },
    {
        "id": 9,
        "name": "LIFE",
        "image": "http://api.androidhive.info/feed/img/life_photo.jpg",
        "status": "In 1965, LIFE photographer Bill Ray spent weeks with the Hells Angels, but his amazing photos never ran in the magazine",
        "profilePic": "http://api.androidhive.info/feed/img/life.jpg",
        "timeStamp": "1403375851930",
        "url": "http://ti.me/1rfcQa4"
    },
    {
        "id": 10,
        "name": "Shakira",
        "image": "http://api.androidhive.info/feed/img/shakira_la_la.png",
        "status": "Download La La La (Brazil 2014) from iTunes:",
        "profilePic": "http://api.androidhive.info/feed/img/shakira.jpg",
        "timeStamp": "1403375851930",
        "url": "http://smarturl.it/FWCalbum?IQid=sh"
    },
    {
        "id": 11,
        "name": "A. R. rahman",
        "image": "http://api.androidhive.info/feed/img/ar_bw.jpg",
        "status": "",
        "profilePic": "http://api.androidhive.info/feed/img/ar.jpg",
        "timeStamp": "1403375851930",
        "url": ""
    }
]
}

以及如何像这样从服务器端获取图像 url

【问题讨论】:

  • 我需要开发一个java服务器端代码以及如何获取服务器图像路径?
  • 表示你的问题是如何写一个webservice???
  • 是的,我如何获取服务器图像路径,我需要将服务器图像路径存储在数据库中
  • 服务器图像路径取决于您在服务器上上传图像的位置。那么只有你可以获取服务器路径。

标签: android android-listview universal-image-loader imagedownload


【解决方案1】:

您可以使用毕加索图书馆。

Picasso.with(context).load("http://api.androidhive.info/feed/img/cosmos.jpg").placeholder(R.drawable.no_image).into(imageView);

【讨论】:

  • 我正在获取 android 端代码。我需要在服务器端开发代码。如何在java服务器中获取api.androidhive.info/feed/img/cosmos.jpg之类的url
  • 你好 Arya,你有关于如何获取服务器图像路径然后将图像服务器路径存储在数据库中并将其返回到 web 服务的问题
  • 尝试 { JSONObject jsonObject = new JSONObject("ResponseString"); JSONArray 数组 = jsonObject.getJSONArray("feed"); for (int i = 0; i
猜你喜欢
  • 1970-01-01
  • 2015-09-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-23
  • 1970-01-01
  • 2017-11-26
  • 1970-01-01
相关资源
最近更新 更多