XListView
第一步:到官网下载第三方包,拷贝到自己的项目中

https://github.com/Maxwin-z/XListView-Android
第二步:xml文件
<me.maxwin.view.XListView
android:id="@+id/xListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000">
</me.maxwin.view.XListView>
第三步:java代码
package com.gcp;
import java.util.ArrayList;
import me.maxwin.view.XListView;
import me.maxwin.view.XListView.IXListViewListener;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ArrayAdapter;
public class XListViewActivity extends Activity implements IXListViewListener {
private XListView mListView; //创建XListView对象
private ArrayAdapter<String> mAdapter;
private ArrayList<String> items = new ArrayList<String>();
private Handler mHandler; //用来模拟网络请求的(不要被迷惑)
private int start = 0;
private static int refreshCnt = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
geneItems();
mListView = (XListView) findViewById(R.id.xListView);
mListView.setPullLoadEnable(true);//上拉刷新
mAdapter = new ArrayAdapter<String>(this, R.layout.list_item, items);//用模拟的数据填充系统的adapter
mListView.setAdapter(mAdapter);//指定adapter
// mListView.setPullLoadEnable(false);
// mListView.setPullRefreshEnable(false);//下拉刷新
mListView.setXListViewListener(this);
//给xListView条目设置监听事件
mHandler = new Handler();
}
private void geneItems() {
for (int i = 0; i != 5; ++i) {
items.add("refresh cnt " + (++start));
}
}
//或的数据后一定要加onLoad()方法,否则刷新会一直进行,根本停不下来
private void onLoad() {
mListView.stopRefresh();
mListView.stopLoadMore();
mListView.setRefreshTime("刚刚");
}
@Override
public void onRefresh() {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
start = ++refreshCnt;
items.clear();
geneItems();
// mAdapter.notifyDataSetChanged();
mAdapter = new ArrayAdapter<String>(XListViewActivity.this, R.layout.list_item, items);
mListView.setAdapter(mAdapter);
onLoad();
}
}, 2000);
}
@Override
public void onLoadMore() {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
geneItems();
mAdapter.notifyDataSetChanged();
onLoad();
}
}, 2000);
}
}
XListView的更多相关文章
- android第三方框架 xlistview 的使用
如今上拉刷新,下拉加载更多已经是浩如烟海的app的标配了 最近正好有相关的需要就去学习了一下,还是那句老话凡事都靠自己来 搞实在不是一件好事,费时费力不说可能还是在做无用功,不过自己研究学习 还是很有 ...
- XListView理念
package com.example.testxml1; import java.io.ByteArrayInputStream;import java.io.InputStream;import ...
- XListView刷新
package com.example.da; import java.util.ArrayList;import java.util.List; import com.badu.net.Networ ...
- xlistview的(java)
package com.bwie.xlistviews; import java.text.SimpleDateFormat;import java.util.Date; import com.bwi ...
- Android Studio添加应用作为依赖时报错Error:Dependency MonthText:xlistview:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. File: 及其解决方案
Error:Dependency MonthText:xlistview:unspecified on project app resolves to an APK archive which is ...
- Android XListView实现原理讲解及分析
XListview是一个非常受欢迎的下拉刷新控件,但是已经停止维护了.之前写过一篇XListview的使用介绍,用起来非常简单,这两天放假无聊,研究了下XListview的实现原理,学到了很多,今天分 ...
- Exception dispatching input event. use XlistView
今天上午解决Bug,一个上午的时间: log: 11-01 14:49:14.826: E/InputEventReceiver(30810): Exception dispatching input ...
- 第三方 XListview 上拉加载、下拉刷新、分页加载和Gson解析
注意:此Demo用的是第三方的Xlistview.jar,需要复制me文件夹到项目中,两个XML布局文件和一张图片 把下面的复制到String中 <string name="xlist ...
- XListview的下拉刷新、上拉加载、用Pull解析XML
做之前需要导入XListview的文件,此是用第三方的xListview实现的,东西没写全.此是在Fragment中实现的 //--------------XListView的布局---------- ...
随机推荐
- Web Scraping with Python读书笔记及思考
Web Scraping with Python读书笔记 标签(空格分隔): web scraping ,python 做数据抓取一定一定要明确:抓取\解析数据不是目的,目的是对数据的利用 一般的数据 ...
- JQuery学习笔记---jquery对象和DOM对象的关系
1.DOM(Document Object Model,文档对象模型).DOM树 { html (head&&body), head(meta && title) ...
- foreach DataTable或Table时要略过第一行。
昨天有续写一个练习<输入数字动态创建行(二)>http://www.cnblogs.com/insus/p/4916260.html ,最终是需要把数据存入数据库中. 在循环ASP:Tab ...
- 基于MVC4+EasyUI的Web开发框架经验总结(12)--利用Jquery处理数据交互的几种方式
在基于MVC4+EasyUI的Web开发框架里面,大量采用了Jquery的方法,对数据进行请求或者提交,方便页面和服务器后端进行数据的交互处理.本文主要介绍利用Jquery处理数据交互的几种方式,包括 ...
- C语言的字符串分割
说起来很有意思,自认为对C语言理解得还是比较深刻的.但居然到今天才知道有个strtok函数,试用了一下突然感慨以前做了多少重复劳动.每次需要解析配置文件,每次需要分割字符串,居然都是自己去分割字符串, ...
- 背水一战 Windows 10 (9) - 资源: 资源限定符概述, 资源限定符示例
[源码下载] 背水一战 Windows 10 (9) - 资源: 资源限定符概述, 资源限定符示例 作者:webabcd 介绍背水一战 Windows 10 之 资源 资源限定符概述 资源限定符示例 ...
- Objective-c 动画
想提高下以后做的应用给客户带去的体验,所以看了几天OC的CAAnimation动画类,也做了几个小案例,下面讲个别案例来做为本文的主要内容. 一:继承结构截图 上面截图中用得最多的类大概就是,CABa ...
- python 三级菜单
三级列表: menu = { '北京':{ '海淀':{ '五道口':{ 'soho':{}, '网易':{}, 'google':{} }, '中关村':{ '爱奇艺':{}, '汽车之家':{}, ...
- c语言语系的命名风格和java系命名风格
c语言系的命名风格:单词之间使用下划线分隔.如上图. java语言是另外一个系,javascript属于java语系(当年就是想借助java的名气所以命名javascript).java语系是驼峰式命 ...
- 《Continuous Delivery》 Notes 1: The problem of delivering software
What is "Deployment pipeline"? A deployment pipeline is an automated implementation of you ...