http://developer.android.com/training/swipe/add-swipe-interface.html

1,在布局xml和代码中使用它

2,在menu中添加它

  The swipe-to-refresh user interface pattern is implemented entirely within the SwipeRefreshLayout widget, which detects the vertical swipe, displays a distinctive progress bar, and triggers callback methods in your app. You enable this behavior by adding the widget to your layout file as the parent of a ListView or GridView, and implementing the refresh behavior that gets invoked when the user swipes.

  This lesson shows you how to add the widget to an existing layout. It also shows you how to add a refresh action to the action bar overflow area, so that users who may be unable to use the swipe gesture can trigger a manual update with an external device.

Add the SwipeRefreshLayout Widget


  To add the swipe to refresh widget to an existing app, add SwipeRefreshLayout as the parent of a singleListView or GridView. Remember that SwipeRefreshLayout only supports a single ListView orGridView child.

  The following example demonstrates how to add the SwipeRefreshLayout widget to an existing layout file containing a ListView:

 <android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"> <ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" /> </android.support.v4.widget.SwipeRefreshLayout>

  You can also use the SwipeRefreshLayout widget with a ListFragment. If the layout contains aListView with the ID "@android:id/list", the swipe-to-refresh functionality is automatically supported. However, explicitly declaring the ListView in this way supersedes the default ListFragment view structure. If you want to use the default view structure, you will have to override parts of the SwipeRefreshLayout andListFragment behavior. For an example of how to do this, see the SwipeRefreshListFragment sample app.

Add a Refresh Action to the Action Bar


  You should add a refresh action to your app's action bar to ensure that users who may not be able to perform a swipe gesture can still trigger a manual update. For example, users with accessibility issues can trigger action bar actions using external devices, such as keyboards and D-pads.

  You should add the refresh action as a menu item, rather than as a button, by setting the attribute android:showAsAction=never. If you display the action as a button, users may assume that the refresh button action is different from the swipe-to-refresh action. By making the refresh action less conspicuous in the action bar, you can encourage users to perform manual updates with the swipe gesture while still maintaining the accessible option in a place where D-pad users would look for it.

  The following code demonstrates how to add the swipe-to-refresh action to the overflow area:

 <menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_refresh"
android:showAsAction="never"
android:title="@string/menu_refresh"/>
</menu>

下拉刷新控件(4)SwipeRefreshLayout官方教程(上)如何在应用中使用它的更多相关文章

  1. 下拉刷新控件(5)SwipeRefreshLayout官方教程(下)响应刷新事件

    http://developer.android.com/training/swipe/respond-refresh-request.html This lesson shows you how t ...

  2. android官方下拉刷新控件SwipeRefreshLayout的使用

    可能开发安卓的人大多数都用过很多下拉刷新的开源组件,但是今天用了官方v4支持包的SwipeRefreshLayout觉得效果也蛮不错的,特拿出来分享. 简介:SwipeRefreshLayout组件只 ...

  3. android SwipeRefreshLayout google官方下拉刷新控件

    下拉刷新功能之前一直使用的是XlistView很方便我前面的博客有介绍 SwipeRefreshLayout是google官方推出的下拉刷新控件使用方法也比较简单 今天就来使用下SwipeRefres ...

  4. Android SwipeRefreshLayout 官方下拉刷新控件介绍

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/24521483 下面App基本都有下拉刷新的功能,以前基本都使用XListView ...

  5. Google SwipeRefreshLayout(Goolge官方下拉刷新控件)尝鲜

    前天Google官方终于出了Android刷新控件——SwipeRefreshLayout. 使用前先需要将android.support.v4.jar升级到19.1.升级后,可能会出现SDK版本与A ...

  6. Android——谷歌官方下拉刷新控件SwipeRefreshLayout(转)

    转自:http://blog.csdn.net/zouzhigang96/article/details/50476402 版权声明:本文为博主原创文章,未经博主允许不得转载. 前言: 如今谷歌推出了 ...

  7. 官方下拉刷新控件SwipeRefreshLayout的使用

    今天看博客,发现有了这个下拉刷新的控件,效果看上去还蛮好的,于是我也想研究的是使用一下,写个demo.其实使用很简单的,但就是为了能使用这个新组建我下了好久的更新,后来还是直接去官网下载最新的ADT得 ...

  8. Android PullToRefresh下拉刷新控件的简单使用

    PullToRefresh这个开源库早就听说了,不过一直没用过.作为一个经典的的开源库,我觉得还是有必要认识一下. 打开github上的网址:https://github.com/chrisbanes ...

  9. Android下拉刷新控件--PullToRefresh的简单使用

    Android中很多时候都会用到上下拉刷新,这是一个很常用的功能,Android的v4包中也为我们提供了一种原生的下拉刷新控件--SwipeRefreshLayout,可以用它实现一个简洁的刷新效果, ...

随机推荐

  1. 【HDOJ】【3516】Tree Construction

    DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[ ...

  2. 【BZOJ】【1008】【HNOI】越狱

    快速幂 大水题= = 正着找越狱情况不好找,那就反过来找不越狱的情况呗…… 总方案是$m^n$种,不越狱的有$m*(m-1)^{n-1}$种= = 负数搞搞就好了…… 莫名奇妙地T了好几发…… /** ...

  3. iOS Automation Test

    google resource for KIF: http://www.oschina.net/translate/ios-ui-testing-with-kif

  4. ios瀑布流

    http://blog.csdn.net/shenjx1225/article/details/9037631

  5. KMP--路过

    HDU 1358:弄清楚了NEXT,就好解决,还有不要再循环中用strlen;会超 ----------------------我是凑字数的------------------还是不会KMP----- ...

  6. Linux关于watch的用法

    Linux关于watch的用法 2011-07-20      0个评论       收藏    我要投稿 watch 是一个非常实用的命令,基本所有的 Linux 发行版都带有这个小工具,如同名字一 ...

  7. 无法激活服务,因为它不支持 ASP.NET 兼容性

    wcf错误直接上图: 原因: 一般是因为程序添加了启用了AJAX的WCF服务而缺少相关设置出现的错误. 解决方案: 1.webconfig <system.serviceModel> &l ...

  8. JS之数组

    1.数组的定义: (1)字面量:  var arr = [1, 2, 3];  (2) new:   var arr = new Array(1, 2, 3);(using new and don't ...

  9. jmeter if 控制器

    判断变量值是不是为空(有没有被赋值): "${jd_aid}"!="\${jd_aid}"

  10. 配置IIS应用程序池

    IIS 6的核心在于工作进程隔离模式,而应用程序池则是定义工作进程如何进行工作,因此,可以说应用程序池是整个IIS 6的核心. 和IIS 5中只能使用单个应用程序池不同,工作在工作进程隔离模式的IIS ...