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. 02.Hibernate映射基础

    前言:Hibernate的核心功能是根据数据库到实体类的映射,自动从数据库绑定数据到实体类.使我们操作实体类(Java对象)就能对数据库进行增.删.查.改,而不用调用JDBC API使数据操作变得简单 ...

  2. LESS CSS 框架简介

    使用 LESS 简化层叠样式表(CSS)的编写 LESS 是动态的样式表语言,通过简洁明了的语法定义,使编写 CSS 的工作变得非常简单.本文将通过实例,为大家介绍这一框架. 简介 CSS(层叠样式表 ...

  3. UML活动图(转载)

    概述: 活动图是另一个重要的UML图来描述系统的动态方面. 活动图基本上是代表流程形成一个活动到另一个活动的流程图.活动可以被描述为一个系统的操作. 因此,绘制控制流从一个操作到另一个.此流可以是连续 ...

  4. 编写单例的 dojo class

    define([ "dojo/_base/declare" ],function( declare ){ var TimeChartService = declare(" ...

  5. mysql SQLyog导入导出csv文件

    1.选择数据库表 --> 右击属性 --> 备份/导出 --> 导出表数据作为 --> 选择cvs --> 选择下面的“更改” --> 字段 --> 变量长度 ...

  6. PHP PDO_MYSQL 操作类 YAF嵌入高性能类而准备

    https://github.com/indieteq/PHP-MySQL-PDO-Database-Class PHP-PDO-MySQL-Class A PHP MySQL PDO class s ...

  7. hdu5017 Ellipsoid(旋转)

    比赛的时候跳进这个大坑里,最后代码是写出来了.看到好像很多都是模拟退火做的,下面提供一个奇怪的思路吧. ax^2+by^2+cz^2+dyz+exz+fxy=1(*) 通过一些奇特的YY我们可以知道这 ...

  8. POJ 2027

    #include<iostream> using namespace std; int main() { int time; cin>>time; int a; int b; ...

  9. asp.net网站中添加百度地图功能

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head ...

  10. JavaScript. The core.

    Read this article in: Japanese, German (version 2), Arabic, Russian, French, Chinese. An object A pr ...