使用到的主要内容:

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. <java基础学习>01环境变量配置

    安装完JDK开始配置系统环境变量,在path变量里面添加java的bin目录 方法二: 配置完成后 在命令下输入javac查看是否配置成功 第一个java程序 hello world! class H ...

  2. 商品sku规格选择效果,没有商品的不能选中,选择顺序不影响展示结果

    <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...

  3. Linux——makefile

    1.vim Makefile 或 vim makefile 2. targetName:a.o b.o   #targetFileName:A.c B.c ,split with a space gc ...

  4. Android按钮的各个样式设置

    安卓开发学习之014 Button应用详解(样式.背景.按钮单击.长按.双击.多击事件) 一.Button简介 按钮也是继承自TextView 二.XML定义方法 <Button android ...

  5. MicroERP1.0简介及下载

    Micro ERP(蓝本)适用于中小微型企事业单位实施信息化管理.本系统研发初始即摒弃了传统ERP所众所周知的诸多繁琐功能,始终坚持以简化流程.平稳实施.快 速应用为切入点.在功能不断完善.健壮的同时 ...

  6. 处理xml c#

    using System.Xml; using System; using System.Text; using System.Net; using System.Collections; using ...

  7. VMware下利用ubuntu13.04建立嵌入式开发环境之二

    之前在VMware中安装完Ubuntu系统,接下来开始设置开发中用到的服务和工具,以及系统设计. 1.安装VMware工具:打开VMware软件,在菜单->VM->Install VMwa ...

  8. 对客户推荐产品模型+python代码

    首先观看数据: l  数据的基本特征用  describe  描述每个基本特征 l  画图画出每个特征的基本统计图 应用import matplotlib.pylab as pl  画图显示 l  关 ...

  9. sqlserver查看所有的外键约束

    select a.name as 约束名, object_name(b.parent_object_id) as 外键表, d.name as 外键列, object_name(b.reference ...

  10. 最小系统加载工具 systemjs

    systemjs 是一个最小系统加载工具,用来创建插件来处理可替代的场景加载过程,包括加载 CSS 场景和图片,主要运行在浏览器和 NodeJS 中.它是 ES6 浏览器加载程序的的扩展,将应用在本地 ...