使用到的主要内容:

1、Json 解析网络数据

2、异步任务加载图片和数据

3、ListView 的内存空间优化(ConvertView)和运行时间优化(ViewHolder)

4、ListView 滚动监听实现分页加载数据

5、动态定义 布局和控件(想实现下拉刷新,好像不是这样实现的..)

  .......

HttpUtil 工具类网络申请数据(用 Gson 解析)

--- 别忘记添加网络权限

<uses-permission android:name="android.permission.INTERNET"/>
 package com.dragon.android.a09_09;

 import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL; /**
* Created by Auser on 2016/9/7.
*/
public class HttpUtil { public static byte[] loadByte(String url){ HttpURLConnection conn = null;
InputStream is = null;
ByteArrayOutputStream baos = null;
try {
conn = (HttpURLConnection) new URL(url).openConnection();
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
is = conn.getInputStream();
baos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024];
int len = -1;
while ((len = is.read(buffer)) != -1) {
baos.write(buffer,0,len);
}
return baos.toByteArray();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (baos!=null){
baos.flush();
baos.close();
}
if (is != null) {
is.close();
}
if (conn != null) {
conn.disconnect();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
} }

HttpUtil

Datas 类存放需要的数据(GsonFormat 插件)

 package com.dragon.android.a09_09;

 import java.util.List;

 /**
* Created by Auser on 2016/9/9.
*/
public class Datas { /**
* code : 99999
* data : {"results":[{"action":0,"actionTime":1472219620657,"candidateCount":85,"caterAvgPrice":"49","caterBranchName":"中心城店","caterBusinessId":"DZ:2213221","caterCategories":"电影院","caterCity":"深圳","caterPhotoUrl":"http://qcloud.dpfile.com/pc/EXgo-1x_xBtU9ZucqX7hTSvd27a8ZWYntDVUaMciJtZbnpM9T49yMmnt4yPiPxuwTYGVDmosZWTLal1WbWRW3A.jpg","caterPlatform":1,"caterRegions":"福田区 市中心区","caterSPhotoUrl":"http://qcloud.dpfile.com/pc/EXgo-1x_xBtU9ZucqX7hTSvd27a8ZWYntDVUaMciJtZwpuORpFhuvgx7Yzr27-sHTYGVDmosZWTLal1WbWRW3A.jpg","caterShopId":382401,"caterTelephone":"0755-82801168","clientStamp":1472219156,"commentCount":201,"createTime":1472219620657,"credit":0,"deviceModel":"iPhone","eventAddress":"福田区福华一路怡景中心城G层","eventCity":"0755","eventCityName":"深圳","eventDateTime":1473420600000,"eventDescription":"简介:\n对于不会说人话情商低,公主病的,\n满嘴脏话,不懂得做人做事的,\n没时间更没兴趣撩你,套路你。\n吃瓜群众别瞎BB,东北人没那么好的脾气,\n会开玩笑的开,开的起玩笑的开,别装逼,\n长得好看你是优势,毕竟是个看脸的时代,\n但你没素质没礼貌就别老自以为自己很美。\n人丑不可怕,就怕你心也丑,做好你自己。\n每个人都差钱,谁也不是银行,但你别差事。\n做人都是相互的,你帮帮我我帮帮你,\n但别觉得一切都是理所当然的。\n能做兄弟做兄弟,能做朋友做朋友,爽快人\n别磨叽。\n\n确定艺人:汪涵,林志颖、任贤齐、\n 萧亚轩、潘玮柏、李荣浩。\n\n待定艺人:许巍","eventExpense":47,"eventKey":"LFCAEL","eventLatitude":22.53608,"eventLocation":"金逸影城","eventLocationUrl":"http://m.dianping.com/shop/2213221?utm_source=open","eventLongitude":114.05923,"eventName":"有趣的灵魂一起去大运体育中心看演唱会","eventRegion":"福田区 市中心区","fee":1,"feeType":{"desc":"我请客","field":"MyTreat","value":1},"guarantee":0,"id":827518,"isMark":false,"multi":0,"opposite":0,"rechargeCred":0,"score":653.0702748285551,"showCount":3670,"state":0,"tagId":"3706","url":"http://www.qingchifan.com/event/detail/827518","user":{"action":1,"age":77,"constellation":"双鱼座","gender":1,"height":180,"isOfficial":"0","lastOnlineTime":"1473358886081","lat":22.54983991655006,"lng":114.1008416972523,"nick":"Mr.Yang","role2":"0","userId":127891,"userImageUrl":"http://img2.chouti.com/QIM/2016090901/7dff30c8e35047fda84bec83128af793.jpg","userKey":"EFCLME"},"userId":127891,"visitorState":0},{"action":0,"actionTime":1473378002766,"candidateCount":1,"caterAvgPrice":"288","caterBranchName":"","caterBusinessId":"DZ:2810071","caterCategories":"自助餐","caterCity":"深圳","caterPhotoUrl":"http://qcloud.dpfile.com/pc/ka5nJiUVP1iEDEInm-5ctFhAg0oTJ6h_JrWwPWyTVSvV-Oie0zXWa0hU-eqGUQgMTYGVDmosZWTLal1WbWRW3A.jpg","caterPlatform":1,"caterRegions":"福田区 市中心区","caterSPhotoUrl":"http://qcloud.dpfile.com/pc/ka5nJiUVP1iEDEInm-5ctFhAg0oTJ6h_JrWwPWyTVSsJDGuWFTd4kmkKP90dcyjBTYGVDmosZWTLal1WbWRW3A.jpg","caterShopId":74869,"caterTelephone":"0755-21513838","clientStamp":1473378002086,"commentCount":5,"createTime":1473378002766,"credit":130,"deviceModel":"Android","eventAddress":"福田区益田路4088号香格里拉大酒店1楼","eventCity":"0755","eventCityName":"深圳","eventDateTime":1474362000000,"eventDescription":"人品是当今社会稀缺而珍贵的品质标签,人品决定态度,态度决定行为,行为决定着最后的结果。女人外表漂亮固然惹人喜爱,但智慧以及谦卑的态度也不可缺少,否则,人就很容易显出骄傲自大、爱慕虚荣等丑恶的特质。","eventExpense":288,"eventKey":"LGLLED","eventLatitude":22.536156,"eventLocation":"福田香格里拉大酒店-鲜咖啡自助餐厅","eventLocationUrl":"http://m.dianping.com/shop/2810071?utm_source=open","eventLongitude":114.057,"eventName":"Buffet\n自助餐","eventRegion":"市中心区","fee":1,"feeType":{"desc":"我请客","field":"MyTreat","value":1},"guarantee":0,"guaranteeCred":0,"id":838810,"isMark":false,"multi":0,"opposite":2,"rechargeCred":0,"score":510.20296508423274,"showCount":22,"state":0,"tagId":"3792","url":"http://www.qingchifan.com/event/detail/838810","user":{"action":1,"age":28,"constellation":"白羊座","gender":1,"height":170,"isOfficial":"0","lastOnlineTime":"1473382864509","lat":22.650712,"lng":114.024987,"nick":"梦卧客","role2":"0","userId":35965,"userImageUrl":"http://img2.chouti.com/group/2016082810/1942adb39d8b69a37fa0887fd55bab9b.jpg","userKey":"GAMBA"},"userId":35965,"visitorState":0},{"action":0,"actionTime":1472372122903,"candidateCount":76,"caterAvgPrice":"366","caterBranchName":"深圳华侨城店","caterBusinessId":"DZ:2723608","caterCategories":"牛排 西餐","caterCity":"深圳","caterPhotoUrl":"http://i3.s2.dpfile.com/pc/f14584fdd425d9a5a70f747f7ebcc6fa(700x700)/thumb.jpg","caterPlatform":1,"caterRegions":"南山区 华侨城 白石洲 益田假日","caterSPhotoUrl":"http://i2.s2.dpfile.com/pc/f14584fdd425d9a5a70f747f7ebcc6fa(278x200)/thumb.jpg","caterShopId":1120,"caterTelephone":"0755-86298729","clientStamp":1472372124606,"commentCount":55,"createTime":1472372122903,"credit":0,"deviceModel":"Android","eventAddress":"南山区深南大道9028号益田假日广场3F","eventCity":"0755","eventCityName":"深圳","eventDateTime":1473417000000,"eventDescription":"一米八左右 干净利落不墨迹 有什么好玩的 求大神带我飞 随时都可以约 带我玩点新鲜的吧 报名了就来私啊

Android之ListView&Json加载网络数据的更多相关文章

  1. Android中ListView异步加载数据

    1.主Activity public class MainActivity extends Activity { private ListView listView; private ArrayLis ...

  2. Android的ListView异步加载图片时,错位、重复、闪烁问题的分析及解决方法

    Android ListView异步加载图片错位.重复.闪烁分析以及解决方案,具体问题分析以及解决方案请看下文. 我们在使用ListView异步加载图片的时候,在快速滑动或者网络不好的情况下,会出现图 ...

  3. wemall app商城源码Android之ListView异步加载网络图片(优化缓存机制)

    wemall-mobile是基于WeMall的android app商城,只需要在原商城目录下上传接口文件即可完成服务端的配置,客户端可定制修改.本文分享wemall app商城源码Android之L ...

  4. UITableView加载网络数据的优化

    UITableView加载网络数据的优化 效果 源码 https://github.com/YouXianMing/Animations // // TableViewLoadDataControll ...

  5. Android中ListView动态加载数据

    1. 引言: 为了提高ListView的效率和应用程序的性能,在Android应用程序中不应该一次性加载ListView所要显示的全部信息,而是采取分批加载策略,随着用户的滑动,动态的从后台加载所需的 ...

  6. Android中ListView分页加载数据

    public class MainActivity extends Activity { private ListView listView=null; //listview的数据填充器 privat ...

  7. Android中ListView异步加载图片错位、重复、闪烁问题分析及解决方案

    我们在使用ListView异步加载图片的时候,在快速滑动或者网络不好的情况下,会出现图片错位.重复.闪烁等问题,其实这些问题总结起来就是一个问题,我们需要对这些问题进行ListView的优化. 比如L ...

  8. Android 实现ListView异步加载图片

    ListView异步加载图片是非常实用的方法,凡是是要通过网络获取图片资源一般使用这种方法比较好,用户体验好,下面就说实现方法,先贴上主方法的代码: package cn.wangmeng.test; ...

  9. Android之ListView异步加载图片且仅显示可见子项中的图片

    折腾了好多天,遇到 N 多让人崩溃无语的问题,不过今天终于有些收获了,这是实验的第一版,有些混乱,下一步进行改造细分,先把代码记录在这儿吧. 网上查了很多资料,发现都千篇一律,抄来抄去,很多细节和完整 ...

随机推荐

  1. 在APACHE服务器上的访问方式上去除index.php

      在APACHE服务器上的访问方式上去除index.php   下面我说下 apache 下 ,如何 去掉URL 里面的 index.php 例如: 你原来的路径是: localhost/index ...

  2. 通过Navicat for MySQL远程连接的时候报错mysql 1130

    1130 重装数据库 解决这个问题

  3. Oracle之内存结构(SGA、PGA)

    一.内存结构 SGA(System Global Area):由所有服务进程和后台进程共享: PGA(Program Global Area):由每个服务进程.后台进程专有:每个进程都有一个PGA. ...

  4. AliOS编译安装MyRocks

    MyRocks是facabook版将自主研发的MySQL分支,其源码位于为:https://github.com/facebook/mysql-5.6/ 首先需要安装以下: sudo yum inst ...

  5. hihoCoder#1014

    刚开始学习C语言,准备在做hiho的题目的过程中来学习,在此进行记录,如果代码中有错误或者不当的地方还请指正. 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小 ...

  6. Y+的一些讨论

    一.关于 fluent计算时壁面函数法和网格的关系,还有一个小问题 1:各位用 fluent的同仁和高手们,我想要比较好的使用 fluent软件,最重要的就是要学好理 论,在这里我想请教各位一个问题, ...

  7. It will affect staff as well.

    Premier Foods has reduced its number of suppliers dramatically in the last 12 months. In 2013 it mad ...

  8. SQLserver日期函数

      ------------------日期转化成年月日时分秒毫秒--------------- select 'R'+CONVERT(varchar(100), GETDATE(), 112)+ri ...

  9. freeCAD特性列表

    通用特性 基本应用 FreeCAD 是跨平台的. 它在 Windows Linux 和 Mac OSX 等平台上运行表现一致. FreeCAD 是图形化应用程序. FreeCAD 基于著名的 GUI ...

  10. Objective C中数组排序几种情况的总结

    总结OC中数组排序3种方法:sortedArrayUsingSelector:;sortedArrayUsingComparator:;sortedArrayUsingDescriptors: 数组排 ...