XListView的使用方法

第一步:

将XlistView,XlistViewHeader,XlistViewFooter三个类复制到工程下,注意修改包名


第二步:

将上面三个类复制到工程后会提示资源文件报错,此时去XlistView开源工程中找到需要的资源文件并赋值到自己的工程下


第三步:在代码中使用XListView

(1)将之前用的ListView组件替换为XListView(全路径名)

(2)在活动中获取组件并进行配置

xlistView = (XListView) findViewById(R.id.xlistView);

		// 下拉刷新是否激活
		xlistView.setPullRefreshEnable(true);
		// 加载更多是否激活
		xlistView.setPullLoadEnable(true);
		// xlistView刷新和加载更多的监听
		xlistView.setXListViewListener(this);

(3)增加三个方法

public void loadOver() {
		// 停止加载更多
		xlistView.stopLoadMore();
		// 停止刷新
		xlistView.stopRefresh();
		//设置刷新时的时间
		xlistView.setRefreshTime(getTime());
		
		
	}

	/**
	 * 刷新
	 */
	@Override
	public void onRefresh() {

		

	}

	/**
	 * 加载更多
	 */
	@Override
	public void onLoadMore() {

		
	}

设置上次刷新时间的方法:

public String getTime(){
	
	
	SimpleDateFormat format=new SimpleDateFormat("hh:mm:ss"); 
	
	Date date=new Date();
	String time = format.format(date);
	return time;
	
	
}




你可能感兴趣的:(XListView的使用方法)