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 ...
随机推荐
- IOS-细节错误
当页面显示时一直奔溃,错误提示-[UICachedDeviceWhiteColor pointSize]: unrecognized selector sent to instance 原因是设置导航 ...
- office project 激活
office project 2010激活方式: 图上中,箭头位置,可能没激活,需要软件激活 ( mini-KMS Activator(Office2010激活工具) V1.2 绿色版 ) 激活方式如 ...
- 经典Linq实例语句
从技术角度而言,LINQ定义了大约40个查询操作符,如select.from.in.where以及order by(C#中).使用这些操作符可以编写查询语句.不过,这些查询还可以基于很多类型的数据,每 ...
- vue.js组件
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- java 记事本 - 实例
记事本记事本实例中使用了以下知识1.ui界面2.io流3.事件监听4.图形5.JFileChooser 类,用于打开文件,另存为文件.弹出文件选择器对话框 学习重点:JFileChooser,有很多方 ...
- 常用SQL语句
一.基础 1.说明:创建数据库 CREATE DATABASE database-name 2.说明:删除数据库 drop database dbname 3.说明:备份sql server --- ...
- ALSA 学习小记
对于playback snd_pcm_begin snd_pcm_commit, 貌似 commit给的frame才会使得alsa去把数据填充 转自 http://magodo.github.io/ ...
- c++中的引用与指针的区别
http://blog.csdn.net/lyd_253261362/article/details/4323691 c++中的引用与指针的区别 ★ 相同点: 1. 都是地址的概念: 指针指向一块内存 ...
- #define中 #与##用法
参考自: http://zjf30366.blog.163.com/blog/static/411164582009061075923/ #include<cstdio> #include ...
- (Tree)94.Binary Tree Inorder Traversal
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * Tre ...