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文件的内容,然后通过 ...
随机推荐
- sql 中实现往表中插入一条记录并返回当前记录的ID
写一条存储过程,实现往User中插入一条记录并返回当前UserId(自增长id) --推荐写法 if(Exists(select * from sys.objects where name=N'Usp ...
- LNK1169: one or more multiply defined symbols found
The build failed due to multiple definitions of one or more symbols. This error is preceded by error ...
- CentOS7下安装Mysql和Memcached 以及 使用C#操作Mysql和Memcached
我本身是学.net的,但是现在很多主流SQL和NOSQL都是部置在linux下,本着好学的精神,前段时间装了个虚拟机,在其装上CentOS64位的服务器系统,对于英文0基础,linux0基础的我来说, ...
- Objective-C语言多态性
动态类型和动态绑定,id可以表示任何指针类型,定义id变量不加* 多态性是指在父类中定义的成员变量和方法被子类继承之后,可以具有不同的数据类型或表现出不同的行为.这使得同一个变量和方法在父类及其各个子 ...
- Jenkins入门系列之——01第一章 Jenkins是什么?
第一章 Jenkins是什么? Jenkins 是一个可扩展的持续集成引擎. 主要用于: l 持续.自动地构建/测试软件项目. l 监控一些定时执行的任务. Jenkins拥有的特性包括: l 易于安 ...
- 报错:org.eclipse.swt.SWTError: No more handles at org.eclipse.swt.SWT.error(SWT.java:4517)
在Mars.Kepler的版本裡,時常會出現以下錯誤導致eclipse無法進行運作 Error.log org.eclipse.swt.SWTError: No more handles at ...
- javadoc 生成文档注释
我们可以通过 javadoc 命令从文档注释中提取内容,生成程序的 API 帮助文档. javadoc -d doc demo.java 文档注释:/******/ @author 标明开发该类模块的 ...
- O2O管理问题怎么解决?
O2O被认为是零售行业的最大变革.O2O模式凭着线上线下一体化融合,无差别的消费体验迅速拉拢了大批希望进军电商的传统零售企业,同时催生了大量以O2O为生的新兴企业.O2O是一种新的消费模式,给消费者带 ...
- Frost R&D
Trees Procedural Math Model in Houdini,render with Mantra. Shader use SurfaceModel With Other Attrib ...
- pyenv ipython jupyter
pyenv pyenv 依赖安装 yum -y install git gcc make patch zlib-devel gdbm-devel openssl-devel sqlite-devel ...