源代码:https://github.com/chrisbanes/Android-PullToRefresh

一.导入类库

将Library文件夹作为Android项目Import到Eclipse。
在要用的项目上右键Properties,Android一栏,Add。

二.Layout

将ListView取代为PullToRefreshListView:

<com.handmark.pulltorefresh.library.PullToRefreshListView android:id="@+id/pull_to_refresh_listview" android:layout_height="fill_parent" android:layout_width="fill_parent" />

三. Activity

// Set a listener to be invoked when the list should be refreshed. PullToRefreshListView pullToRefreshView = (PullToRefreshListView) findViewById(R.id.pull_to_refresh_listview); pullToRefreshView.setOnRefreshListener(new OnRefreshListener<ListView>() { @Override public void onRefresh(PullToRefreshBase<ListView> refreshView) { // Do work to refresh the list here. new GetDataTask().execute(); } }); private class GetDataTask extends AsyncTask<Void, Void, String[]> { ... @Override protected void onPostExecute(String[] result) { // Call onRefreshComplete when the list has been refreshed. pullToRefreshView.onRefreshComplete(); super.onPostExecute(result); } }
四. 取得内部控件

The first thing to know about this library is that it is a wrapper around the existing View classes.
So if you use this library and want to get access to the internal ListView/GridView/etc then simply call getRefreshableView(). You can then call all of your usual methods such as setOnClickListener() etc.

更多相关文章

  1. 没有一行代码,「2020 新冠肺炎记忆」这个项目却登上了 GitHub 中
  2. 不吹不黑!GitHub 上帮助人们学习编码的 12 个资源,错过血亏...
  3. android 实现拖动效果
  4. Android高版本不兼容低版本gradle问题
  5. 在eclipse中查看Android各版本源代码
  6. android Settings项目安装
  7. android 学习 ----控件学习 选项卡。
  8. 转-Android之PreferenceActivity
  9. Android(安卓)Studio 项目gradle构建 仓库切换国内阿里源。

随机推荐

  1. 【不负初心】Android初中高级开发工程师
  2. Android 网络请求简单使用方式
  3. android 音视频直播
  4. ubuntu下adb调试android找不到设备的解决
  5. 红透半边天的Android
  6. android输入框一条线和一个框两种样式的
  7. lua学习笔记 3 android调用Lua。Lua脚本
  8. 嵌入数据库SQLite(3) - Android
  9. [转载]Android(安卓)HAL简介
  10. Android中init.rc文件的解析