android 5.0新特性学习总结之下拉刷新(一)
android 5.0 后google最终在 support v4 包下 添加了下拉刷新的控件
项目地址: https://github.com/stormzhang/SwipeRefreshLayoutDemo
xml:
<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" >
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp" />
</android.support.v4.widget.SwipeRefreshLayout>
java:
实现监听:
implements SwipeRefreshLayout.OnRefreshListener
/*
* 监听器SwipeRefreshLayout.OnRefreshListener中的方法,当下拉刷新后触发
*/
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// 停止刷新
mSwipeLayout.setRefreshing(false);
}
}, 5000); // 5秒后发送消息,停止刷新
}
初始化下拉刷新控件
mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
mSwipeLayout.setOnRefreshListener(this);
// 设置下拉圆圈上的颜色,蓝色、绿色、橙色、红色
mSwipeLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light,
android.R.color.holo_orange_light, android.R.color.holo_red_light);
mSwipeLayout.setDistanceToTriggerSync(400);// 设置手指在屏幕下拉多少距离会触发下拉刷新
mSwipeLayout.setProgressBackgroundColor(R.color.red); // 设定下拉圆圈的背景
mSwipeLayout.setSize(SwipeRefreshLayout.LARGE); // 设置圆圈的大小
/*
* 监听器SwipeRefreshLayout.OnRefreshListener中的方法,当下拉刷新后触发
*/
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// 停止刷新
mSwipeLayout.setRefreshing(false);
}
}, 5000); // 5秒后发送消息,停止刷新
}
初始化下拉刷新控件
mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
mSwipeLayout.setOnRefreshListener(this);
// 设置下拉圆圈上的颜色,蓝色、绿色、橙色、红色
mSwipeLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light,
android.R.color.holo_orange_light, android.R.color.holo_red_light);
mSwipeLayout.setDistanceToTriggerSync(400);// 设置手指在屏幕下拉多少距离会触发下拉刷新
mSwipeLayout.setProgressBackgroundColor(R.color.red); // 设定下拉圆圈的背景
mSwipeLayout.setSize(SwipeRefreshLayout.LARGE); // 设置圆圈的大小
android 5.0新特性学习总结之下拉刷新(一)的更多相关文章
- android 5.0新特性学习--视图阴影
android 5.0的视图阴影主要是体验出层次性,就是在一个物体上面叠加上一层的设计,而这种设计就是除了传统的,x,y的纸面层,还有就是透过纸面的z轴的层次设计. elevation: 高度,静态属 ...
- android 5.0新特性学习--RecyclerView
在过去很多年,我们的PC或者手机设备都是采用拟物化的设计风格,IOS采用扁平化的特性,android在2014年IO大会上说采用Material Design的设计风格,显示效果不能过于生硬的转换,而 ...
- android 5.0新特性学习--Drawable Tinting(为图片资源着色)
使用android:tint属性去调整色调.android:tintMode 着色模式 screen multiply and src_atop/src_in/src_oversetTint(int ...
- android 5.0新特性学习--视图轮廓
ViewOutlineProvider -- 视图轮廓setOutlineProvider--可以使用View.setClipToOutline方法去剪切一个视图的outline区域.只有rectan ...
- android 5.0新特性学习--CardView
CardView继承自FrameLayout类,可以在一个卡片布局中一致性的显示内容,卡片可以包含圆角和阴影.CardView是一个Layout,可以布局其他View. 官网地址:https://de ...
- Android 6.0 新特性 整理 资料来自网络
Android 6.0新特性 Runtime Permissions Doze and App Standby Apache HTTP Client Removal BoringSSL Access ...
- Android 8.0 新特性
Android 8.0 (Android Oreo(奥利奥))新特性介绍 通知渠道 - Notification Channels 通知渠道是由应用自行定义的通知内容类别,借助渠道,开发者可以让用户对 ...
- android 7.0 新特性 和对开发者的影响
android 7.0新特性 - jiabailong的专栏 - 博客频道 - CSDN.NEThttp://blog.csdn.net/jiabailong/article/details/5241 ...
- 腾讯云安全:开发者必看|Android 8.0 新特性及开发指南
欢迎大家关注腾讯云技术社区-博客园官方主页,我们将持续在博客园为大家推荐技术精品文章哦~ 背景介绍 谷歌2017 I/O开发者大会今年将于5月17-19日在美国加州举办.大会将跟往年一样发布最新的 A ...
随机推荐
- JSP执行原理图
- scala 变量定义,基本操作符
scala是jvm语言,它将面向对象与函数风格结合的很好,它可以访问任何java类库并很好的结合使用. 它可以使程序更简单,同时可利用并发的威力. scala基本语法: package com.tes ...
- 12 C#中的方法
还记得我们的第一个程序吗?忘记了?那你要努力了.我们的第一个程序是就是往dos窗口输出一些字符串.在哪个程序中只有一个方法,Main方法.Main方法是一个特殊的方法,但是它也是一个方法.为什么说Ma ...
- Hive扩展功能(六)--HPL/SQL(可使用存储过程)
软件环境: linux系统: CentOS6.7 Hadoop版本: 2.6.5 zookeeper版本: 3.4.8 主机配置: 一共m1, m2, m3这五部机, 每部主机的用户名都为centos ...
- Codeforces_732D_(二分贪心)
D. Exams time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- HDU_1158_Employment Planning_dp
Employment Planning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...
- Node.js之错误处理
Node.js之错误处理 1. 使用 domain 模块处理错误 try..catch 多用于捕捉同步方法中的抛出错误,但不能用try..catch捕捉异步方法中抛出de错误 如: 1 var htt ...
- C#学习笔记_09_构造方法/函数
09_构造方法/函数 代码案例 作用:构造函数主要是用来创建对象时为对象赋初值来初始化对象:总与new运算符一起使用在创建对象的语句中,例如A a=new A(); 特点: 构造函数具有和类一样的名称 ...
- Python中的@property装饰器
要了解@property的用途,首先要了解如何创建一个属性. 一般而言,属性都通过__init__方法创建,比如: class Student(object): def __init__(self,n ...
- Linux - redis哨兵集群实例
目录 Linux - redis哨兵集群实例 命令整理 配置流程 Linux - redis哨兵集群实例 命令整理 官网地址:http://redisdoc.com/ redis-cli info # ...
