使用到的主要内容:

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. win7系统 .chm文件打不开的解决办法

    一.正确操作方法1.鼠标右键单击该CHM文件,在右键快捷窗口中选择“打开方式”-“Microsoft HTML Help Executable”:2.如果出现一个提示窗口,大意是说,该CHM文件的发行 ...

  2. Text Justification

    在一段时间没刷题之后,我发现脑子严重地滞涩了.这题AC花了好大力气,出现了Memory Limit Exceed,Core Dump,以及各种普通的编译.运行错误.MLE 和 CD错误是比较难检查的, ...

  3. JQuery 判断不同浏览器

    if($.browser.msie) {          //IE浏览器alert("this is msie"); } else if($.browser.safari)   ...

  4. stella mccartney falabella foldover tote a few eye observed

    Lately, the particular Heyuan City Courtroom retrial, in order to commit the criminal offense of cou ...

  5. AliOS编译安装MyRocks

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

  6. MYSQL5.7无法启动服务原因及解决方案

    mysql5.7安装完成后,想要把它发布成windows服务: 首先,应该配置新的配置文件,然后将cmd打开到安装目录的bin文件,键入: mysqld --default-file="D: ...

  7. SYS与SYSTEM、DBA与SYSDBA的区别

    SYS与SYSTEM: 1. sys 的角色是sysdba system 的角色是sysoper 2. sys 具有create database的权限 system没有该权限 3. sys可以建数据 ...

  8. output和returnvalue的作用

    贴两段代码. 1> public int ExecuteNonQuery(string pro, MobileOrder or)        {            SqlParameter ...

  9. 常用js字符串方法学习总结

    2016-06-15 js数组和字符串方法有很多,并且有一部分在使用的过程中有很多方法是很容易被混淆的,今天来总结一下js中数组和字符串的方法. ♦数组(Array)的方法 1.push() 和 po ...

  10. jenkins配置

    自动化测试机器172,27.14.22   IP 一.jenkins要先登录——>点击JCF_Automation——>点击左边配置 二.环境变量赋值就不会把进程杀掉