Android很酷的下拉刷新源码:Taurus

jopen 7年前

一个很酷的下拉刷新源码,下拉会出现一架起飞的飞机。在布局中添加PullToRefreshView

<com.yalantis.taurus.PullToRefreshView      android:id="@+id/pull_to_refresh"      android:layout_width="match_parent"      android:layout_height="match_parent"      app:type="sun">         <ListView          android:id="@+id/list_view"          android:divider="@null"          android:dividerHeight="0dp"          android:layout_width="match_parent"          android:layout_height="match_parent" />     </com.yalantis.taurus.PullToRefreshView>

在onCreate中设置监听者

mPullToRefreshView = (PullToRefreshView) findViewById(R.id.pull_to_refresh);  mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() {      @Override      public void onRefresh() {          mPullToRefreshView.postDelayed(new Runnable() {              @Override              public void run() {                  mPullToRefreshView.setRefreshing(false);              }          }, REFRESH_DELAY);      }   });


运行效果: