Android之官方下拉刷新控件SwipeRefreshLayout
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的更多相关文章
- Android——谷歌官方下拉刷新控件SwipeRefreshLayout(转)
转自:http://blog.csdn.net/zouzhigang96/article/details/50476402 版权声明:本文为博主原创文章,未经博主允许不得转载. 前言: 如今谷歌推出了 ...
- android官方下拉刷新控件SwipeRefreshLayout的使用
可能开发安卓的人大多数都用过很多下拉刷新的开源组件,但是今天用了官方v4支持包的SwipeRefreshLayout觉得效果也蛮不错的,特拿出来分享. 简介:SwipeRefreshLayout组件只 ...
- 官方下拉刷新控件SwipeRefreshLayout的使用
今天看博客,发现有了这个下拉刷新的控件,效果看上去还蛮好的,于是我也想研究的是使用一下,写个demo.其实使用很简单的,但就是为了能使用这个新组建我下了好久的更新,后来还是直接去官网下载最新的ADT得 ...
- 【转】Android官方下拉刷新控件 SwipeRefreshLayout
今天在Google+上看到了SwipeRefreshLayout这个名词,遂搜索了下,发现竟然是刚刚google更新sdk新增加的一个widget,于是赶紧抢先体验学习下. SwipeRefreshL ...
- 第一个开源控件:Google 官方下拉刷新控件 SwipeRefreshLayout 强化版,支持上拉刷新
最近比较闲,所以趁着这时间撸了个SwipeRefreshLayout的加强版,Github地址. 原版只支持下拉刷新,强化之后支持上拉刷新和一进入页面就加载刷新,整个控件的加载动画是一致的,毫无违和感 ...
- Android SwipeRefreshLayout 官方下拉刷新控件介绍
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/24521483 下面App基本都有下拉刷新的功能,以前基本都使用XListView ...
- android SwipeRefreshLayout google官方下拉刷新控件
下拉刷新功能之前一直使用的是XlistView很方便我前面的博客有介绍 SwipeRefreshLayout是google官方推出的下拉刷新控件使用方法也比较简单 今天就来使用下SwipeRefres ...
- Google SwipeRefreshLayout(Goolge官方下拉刷新控件)尝鲜
前天Google官方终于出了Android刷新控件——SwipeRefreshLayout. 使用前先需要将android.support.v4.jar升级到19.1.升级后,可能会出现SDK版本与A ...
- google官方提供的下拉刷新控件SwipeRefreshLayout
摘自:http://www.stormzhang.com/android/2014/03/29/android-swiperefreshlayout/ SwipeRefreshLayout Swipe ...
随机推荐
- spring mvc 深入学习
参考文章: 第二章 Spring MVC入门 —— 跟开涛学SpringMVC Spring MVC 3.0 深入总结:http://blog.csdn.net/sunitjy/article/det ...
- android模拟器停在Waiting for HOME解决方案
直接打开Android SDK Manager然后再从Android SDK Manager里的tools打开Android AVD Manager,删除掉在Eclipse里创建的模拟器.并在新建一个 ...
- 很不错的在线Office控件:IWebOffice与SOAOffice
http://blog.csdn.net/cjh200102/article/details/17220441 iWebOffice2003文档控件 iWebOffice2003网络文档中间件能够在I ...
- ASP.NET管道
以IIS 6.0为例,在工作进程w3wp.exe中,利用Aspnet_ispai.dll加载.NET运行时(如果.NET运行时尚未加载).IIS 6引入了应用程序池的概念,一个工作进程对应着一个应用程 ...
- Scala的几个小tips
1. Main方法只能写在object而不是class里 2. Unit test只能针对class或者trait,不能给object做,解决方法,把object里面要测的方法拿出来放到trait里, ...
- 我用VS2012在Nuget中安装Signalr之后报错
我用VS2012在Nuget中安装Signalr之后报错 “/”应用程序中的服务器错误. The following errors occurred while attempting to load ...
- PSP(11.9~11.16)
14号 类别c 内容c 开始时间s 结束e 中断I 净时间T 看书 设计模式 15:20 17:10 25m 85m 看书 构建执法 19:00 20:10 0m 70m 15号 类别c 内容c 开始 ...
- java写入文件之txt文本
FileWriter fw=new FileWriter("D:\\test.txt") fw.write("文本值") fw.flush() fw.close ...
- 关于Jquery中的$.each获取各种返回类型数据的使用方法
var arr = [ "one", "two", "three", "four"]; $.each(arr, func ...
- Hive On Spark概述
Hive现有支持的执行引擎有mr和tez,默认的执行引擎是mr,Hive On Spark的目的是添加一个spark的执行引擎,让hive能跑在spark之上: 在执行hive ql脚本之前指定执行引 ...