SwipeRefreshLayout 是在V4包里面,首先要先导入V4包,最新的V4包里面才有这控件

首先是布局

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent" > <ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" > <TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/hello_world" > </TextView>
</ScrollView> </android.support.v4.widget.SwipeRefreshLayout>

SwipeRefreshLayout 中嵌入一个可滑动的控件,可以是scrollview  也可以是listview  gridview

package com.example.swiperrefreshlayout;

import android.os.Bundle;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
import android.text.SpanWatcher;
import android.view.Menu;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Interpolator;
import android.widget.TextView; @SuppressLint("NewApi")
public class MainActivity extends Activity { SwipeRefreshLayout swiper;
ObjectAnimator oa;
TextView text;
private Interpolator accelerator = new AccelerateInterpolator();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
swiper=(SwipeRefreshLayout) findViewById(R.id.swipe_container);
swiper.setOnRefreshListener(new listener());
text=(TextView) findViewById(R.id.text); //显示或隐藏刷新进度条
swiper.setRefreshing(false);
// 设置进度条的颜色主题,最多能设置四种
swiper.setColorScheme(android.R.color.holo_blue_bright,
android.R.color.holo_green_light,
android.R.color.holo_orange_light,
android.R.color.holo_red_light); oa=ObjectAnimator.ofFloat(swiper, "rotationY", 0f,-180f);
oa.setDuration(600);
oa.setRepeatCount(1);
oa.setRepeatMode(ObjectAnimator.REVERSE);
oa.setInterpolator(accelerator);
// Animation an=new Animation();
}
class listener implements OnRefreshListener{ @Override
public void onRefresh() {
// TODO Auto-generated method stub
oa.start(); if(swiper.isRefreshing()){
text.setText("正在刷新");
}else{
text.setText("停止刷新");
};
//swiper.
} }
}

Android之官方下拉刷新控件SwipeRefreshLayout的更多相关文章

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

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

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

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

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

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

  4. 【转】Android官方下拉刷新控件 SwipeRefreshLayout

    今天在Google+上看到了SwipeRefreshLayout这个名词,遂搜索了下,发现竟然是刚刚google更新sdk新增加的一个widget,于是赶紧抢先体验学习下. SwipeRefreshL ...

  5. 第一个开源控件:Google 官方下拉刷新控件 SwipeRefreshLayout 强化版,支持上拉刷新

    最近比较闲,所以趁着这时间撸了个SwipeRefreshLayout的加强版,Github地址. 原版只支持下拉刷新,强化之后支持上拉刷新和一进入页面就加载刷新,整个控件的加载动画是一致的,毫无违和感 ...

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

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

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

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

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

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

  9. google官方提供的下拉刷新控件SwipeRefreshLayout

    摘自:http://www.stormzhang.com/android/2014/03/29/android-swiperefreshlayout/ SwipeRefreshLayout Swipe ...

随机推荐

  1. 长年承接AR图像识别项目,关于高速UnityARCam多图问题技术整理

    //关于高通ARCameraQCARBehaviour script下 Max Simultneous Image QCARBehaviour script下 Max Simultneous Imag ...

  2. WPF嵌入Unity3D代码下载

    这不是大家想找的资源,这是给我的一个帖子用的.当然可以使用u3d自带编译器打开.这是给wpf 嵌入u3d的例子贴用http://bbs.csdn.net/topics/391853486?page=1 ...

  3. WIN SERVER 2008 R2 VPN

    http://blog.csdn.net/popelovevivi/article/details/9408851 -- 还差最重要一步. 在“本地用户和组”-“用户”-右键一个你想VPN登录的用户名 ...

  4. css3基础、(弹性、响应式)布局注意点

    E1>E2选择父元素为E元素的所有E2元素(子类选择器) E1+E2选择元素为E1之后的所有E2元素(兄弟选择器) E[attr]只使用属性名,但没有确定任何属性值 E[attr="v ...

  5. DOJO DOM 功能

    In this tutorial, you'll learn about how to use Dojo to manipulate the DOM in a simple, cross-browse ...

  6. python的with...as用法

    with...as叫做上下文管理器,作用是进入一个对象的作用域和离开时,可以执行执行一定的操作.这个操作是可以自己 设定的. 写个例子学习一下: class test(): def __init__( ...

  7. oracle 导库建立测试库

    由于客户要定制的关系,需要对产品的数据进行相关的修改,所以需要复制原来的库出来,然后在此基础上再进行修改.步骤如下: 在PL/SQL下操作: /*分为四步 *//*第1步:创建临时表空间  */cre ...

  8. java 验证手机号码、电话号码(包括最新的电信、联通和移动号码)

    一.目前的号码段(2016-12-8更新)   二.代码 package com.test; import java.util.regex.Pattern; public class CheckPho ...

  9. Ubuntu1404 (1)

    0.初始设置 (1)开户root账号并重启系统: sudo gedit /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf, 添加greeter-show ...

  10. 支持Java Spring MVC

    Java Spring MVC能很方便在后台返回JSON数据,所以与MiniUI进行数据交互非常简单. 1)后台处理: 在MVC控制器中,可以通过方法参数接收数据,也可以通过Request接收更复杂的 ...