XListView理念
package com.example.testxml1;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import me.maxwin.view.XListView;
import me.maxwin.view.XListView.IXListViewListener;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import com.example.adapter.MyBAdapter;
import com.example.bean.Bean;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ListView;
import android.R.integer;
import android.app.Activity;
public class MainActivity extends Activity implements IXListViewListener{
private HttpUtils httpUtils;
private List<Bean> lists = new ArrayList<Bean>();
private List<Bean> listss;
private XListView xlistView;
private int start1 = 12;
private Handler handler;
private MyBAdapter adapter;
private static int refereshCnt = 0 ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
xlistView = (XListView) findViewById(R.id.xlistview);
xlistView.setPullLoadEnable(true);
xlistView.setPullRefreshEnable(true);
xlistView.setXListViewListener(this);
for (int i = 11; i != start1; i++) {
getdata(start1);
}
adapter = new MyBAdapter(lists, MainActivity.this);
xlistView.setAdapter(adapter);
handler = new Handler();
}
private void getdata(int start) {
httpUtils = new HttpUtils();
httpUtils.send(HttpMethod.GET, "http://v.juhe.cn/laohuangli/h?date=2014-09-"+start+"&key=8097aa39feea4ac842b05424e9de355a&dtype=xml", new RequestCallBack<String>() {
@Override
public void onFailure(HttpException arg0, String arg1) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(ResponseInfo<String> arg0) {
// TODO Auto-generated method stub
String uri = arg0.result;
try {
InputStream is = new ByteArrayInputStream(uri.getBytes());
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(is);
Element element = document.getDocumentElement();
NodeList list = element.getElementsByTagName("item");
for (int i = 0; i < list.getLength(); i++) {
Bean b = new Bean();
Element e = (Element) list.item(i);
b.setYangli(e.getElementsByTagName("yangli").item(0).getTextContent());
b.setHours(e.getElementsByTagName("hours").item(0).getTextContent());
b.setDes(e.getElementsByTagName("des").item(0).getTextContent());
b.setYi(e.getElementsByTagName("yi").item(0).getTextContent());
b.setJi(e.getElementsByTagName("ji").item(0).getTextContent());
lists.add(b);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
@Override
public void onRefresh() {
// TODO Auto-generated method stub
handler.postDelayed(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
start1 = ++refereshCnt;
lists.clear();
getdata(start1);
adapter.notifyDataSetChanged();
onLoad();
}
}, 2000);
}
@Override
public void onLoadMore() {
// TODO Auto-generated method stub
handler.postDelayed(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
getdata(start1);
adapter.notifyDataSetChanged();
onLoad();
}
}, 2000);
}
public void onLoad() {
// TODO Auto-generated method stub
xlistView.stopLoadMore();
xlistView.stopRefresh();
xlistView.setRefreshTime("刚刚");
};
}
XListView理念的更多相关文章
- atitit.attilax的软件 架构 理念.docx
atitit.attilax的软件 架构 理念.docx 1. 预先规划.1 2. 全体系化1 3. 跨平台2 4. 跨语言2 5. Dsl化2 5.1. 界面ui h5化2 6. 跨架构化2 7. ...
- 女生的最爱,装饰品。WPF也有,Adorner。(上海晒衣服理念)
说到装饰,不由要说到女性. 去年过年回家给我妈买了周大福项链,很明显就感觉待遇就不一样了,即使这样,还是被一个阿姨说应该买更重点的.看来钱这种东西果然是多一点才好.虽然自己无所谓,但让家里人更开心也是 ...
- 【翻译】理念:无冲突的扩展本地DOM原型
菜鸟翻译,望大家多多指正哈 原文:http://lea.verou.me/2015/04/idea-extending-native-dom-prototypes-without-collisions ...
- 张艾迪(创始人):Be.Time+Cr.Idear的创新理念
The World No.1 Girl :Eidyzhang The World No.1 Internet Girl :Eidyzhang AOOOiA.global Founder :Eidyzh ...
- XListView
第一步:到官网下载第三方包,拷贝到自己的项目中 https://github.com/Maxwin-z/XListView-Android 第二步:xml文件 <me.maxwin.view.X ...
- android第三方框架 xlistview 的使用
如今上拉刷新,下拉加载更多已经是浩如烟海的app的标配了 最近正好有相关的需要就去学习了一下,还是那句老话凡事都靠自己来 搞实在不是一件好事,费时费力不说可能还是在做无用功,不过自己研究学习 还是很有 ...
- XListView刷新
package com.example.da; import java.util.ArrayList;import java.util.List; import com.badu.net.Networ ...
- paip.多维理念 输入法的外码输入理论跟文字输出类型精髓
paip.多维理念 输入法的外码输入理论跟文字输出类型精髓 通常,我们的输入法使用的外码是拼音,但是,这个的用户体验很差.. 应该使用多个外码类型... ##按照词汇来源,有如下几个 固有词ati 来 ...
- paip.元数据驱动的转换-读取文件行到个list理念 uapi java php python总结
paip.元数据驱动的转换-读取文件行到个list理念 uapi java php python总结 #两个思路 1.思路如下:使用file_get_contents()获取txt文件的内容,然后通过 ...
随机推荐
- struts2数据校验与国际化
数据校验: Action里的validate()方法能校验action类所有的方法,如果有错,如:addFieldError,会自动返回到workflow校验拦截器不向下继续进行,不用return i ...
- UVM中的class--2
1)uvm_component从uvm_report_object继承而来,提供的功能包括: 1)Hierarchy,-----searching and traversing component h ...
- 《zw版·Halcon-delphi系列原创教程》 Halcon分类函数009,Measure,测量函数
<zw版·Halcon-delphi系列原创教程> Halcon分类函数009,Measure,测量函数 为方便阅读,在不影响说明的前提下,笔者对函数进行了简化: :: 用符号“**”,替 ...
- Openstack的web管理端相关
openstack的web管理端技术方面要关注的问题. 同步?异步 先说浏览器的同步和异步,我们知道的浏览器可以使用ajax实现异步请求,就是浏览器在请求数据的时候,我们管理员还能对浏览器就行其他操作 ...
- shell 显示字体颜色
(2).颜色语法: \033[前景色;背景色m \033[0m #0m代表恢复到系统默认的颜色 (3).字符界面前景颜色与背景颜色: 前 ...
- 安装ntp服务,并设置ntp客户端
1.yum安装ntp [root@localhost ~]# yum install ntp 2.修改配置文件 配置文件在/etc/ntp.conf
- 2016年12月25日 星期日 --出埃及记 Exodus 21:20
2016年12月25日 星期日 --出埃及记 Exodus 21:20 "If a man beats his male or female slave with a rod and the ...
- WebForm水印照片
水印照片需要的元素 绘制:1.画布2.画笔 样式 粗细 颜色3.画什么东西4.用什么字体画 大小5.位置 展示页面 <%@ Page Language="C#" AutoEv ...
- src url href uri的区别和联系
- Point ZM 转换为Point 类型
打开ArcToolbox,使用ConvertionTools-> To Shapefile->FeatureClass to Shapefile 工具,注意在环境设置里,里将output ...