今天看了一个Android-PullToRefresh的开源项目,用于上拉、下拉刷新显示内容,下载项目源码https://github.com/fengcunhan/Android-PullToRefresh,里面包含三个文件夹
将库和例子代码导入到工程中,并将库添加到例子程序中,修改平台至无错误出现,浏览PullToRefreshListActivity代码,布局文件如下
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!--
The PullToRefreshListView replaces a standard ListView widget.
-->
<com.handmark.pulltorefresh.library.PullToRefreshListView
xmlns:ptr="http://schemas.android.com/apk/res/com.handmark.pulltorefresh.sample"
android:id="@+id/pull_refresh_list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
ptr:mode="both"
/>
</LinearLayout>
在该项目的文档中说明了如果上拉下拉都使能时的设置,activity的代码很简单,只是一个列表显示
public class PullToRefreshListActivity extends ListActivity {
static final int MENU_MANUAL_REFRESH = 0;
static final int MENU_DISABLE_SCRO