SwipeRefreshLayout嵌套ScrollView实现下拉刷新
效果:

使用超级简单!
在layout中添加SwipeRefreshLayout
<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="wrap_content" > <TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="10dp"
android:text="@string/swipe_to_refresh"
android:textSize="20sp"
android:textStyle="bold" />
</ScrollView> </android.support.v4.widget.SwipeRefreshLayout>
在Activity中使用:
tv = (TextView)findViewById(R.id.textView1);
swipeRefreshLayout = (SwipeRefreshLayout)findViewById(R.id.swipe_container);
//设置刷新时动画的颜色,可以设置4个
swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light);
swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override
public void onRefresh() {
tv.setText("正在刷新");
// TODO Auto-generated method stub
new Handler().postDelayed(new Runnable() { @Override
public void run() {
// TODO Auto-generated method stub
tv.setText("刷新完成");
swipeRefreshLayout.setRefreshing(false);
}
}, );
}
});
PS:setColorScheme()已经弃用,使用setColorSchemeResources()来设置颜色。
SwipeRefreshLayout嵌套ScrollView实现下拉刷新的更多相关文章
- [RN] React Native 使用 FlatList 和 ScrollView 的下拉刷新问题
React Native 使用 FlatList 和 ScrollView 实现 下拉刷新时,RefreshControl 控件不起作用, 后来经查明,原来 RefreshControl 要加在 Sc ...
- Google SwipeRefreshLayout(Goolge官方下拉刷新控件)尝鲜
前天Google官方终于出了Android刷新控件——SwipeRefreshLayout. 使用前先需要将android.support.v4.jar升级到19.1.升级后,可能会出现SDK版本与A ...
- SwipeRefreshLayout的使用,下拉刷新
1. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android ...
- Google自己的下拉刷新组件SwipeRefreshLayout
SwipeRefreshLayout SwipeRefreshLayout字面意思就是下拉刷新的布局,继承自ViewGroup,在support v4兼容包下,但必须把你的support librar ...
- Android listview下拉刷新 SwipeRefreshLayout
今天在Google+上看到了SwipeRefreshLayout这个名词,遂搜索了下,发现竟然是刚刚google更新sdk新增加的一个widget,于是赶紧抢先体验学习下. SwipeRefreshL ...
- google官方提供的下拉刷新控件SwipeRefreshLayout
摘自:http://www.stormzhang.com/android/2014/03/29/android-swiperefreshlayout/ SwipeRefreshLayout Swipe ...
- 【转】Android官方下拉刷新控件 SwipeRefreshLayout
今天在Google+上看到了SwipeRefreshLayout这个名词,遂搜索了下,发现竟然是刚刚google更新sdk新增加的一个widget,于是赶紧抢先体验学习下. SwipeRefreshL ...
- Android Material Design控件使用(四)——下拉刷新 SwipeRefreshLayout
使用下拉刷新SwipeRefreshLayout 说明 SwipeRefreshLayout是Android官方的一个下拉刷新控件,一般我们使用此布局和一个RecyclerView嵌套使用 使用 xm ...
- Google官方下拉刷新组件---SwipeRefreshLayout
今天在Google+上看到了SwipeRefreshLayout这个名词,遂搜索了下,发现竟然是刚刚google更新sdk新增加的一个widget,于是赶紧抢先体验学习下. SwipeRefreshL ...
随机推荐
- Docker中使用createdump调试coreclr
应用上线后可能出现一些问题,通过源码排查,日志分析都不能确定具体原因的情况下,可以使用dump转存文件分析,netcore对于linux系统dump提供了createdump工具,配合lldb sos ...
- MySQL笔记(4)---表
1.前言 上一章记录了MySQL中的一些文件组成,以及相关作用和参数配置,本章开始记录深层次的存储结构,以便更好理解MySQL的设计. 2.索引组织表 InnoDB中,表都是根据主键顺序组织存放的,这 ...
- RESTful API后台系统架构设计(Java)
最近设计和实现了一个JAVA的RESTful API的后台业务系统架构,主要基于Java平台.设计要求是: 性能:平均响应时间(RESTful API)小于2s(平均负载的情况下),并发访问200个以 ...
- 三:理解Page类的运行机制(例:在render方法中生成静态文件)
我这里只写几个常用的事件1.OnPreInit:此事件后将加载个性化信息和主题2.OnInit:初始化页面中服务器控件的默认值但控件的状态没有加载,没有创建控件树3.OnPreLoad:控件完成状态和 ...
- CentOS qt5 /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found
1.下载QT5 SDK 下载地址:http://qt-project.org/downloads. 2.安装QT5 下载完后,假设放在Download/,切换到该目录,输入:./qt-linux-op ...
- JSONPath使用说明
# JSONPath - XPath for JSON A frequently emphasized advantage of XML is the availability of plenty t ...
- normalize.css 中文版
## normalize.css 中文版 normalize.css 原地址:http://necolas.github.io/normalize.css/reset 太暴力了,这个 normaliz ...
- [转]腾讯云Linux云服务器文件上传利器——WinSCP
本文转自:http://bbs.qcloud.com/thread-4379-1-1.html WinSCP简介 WinSCP是一个Windows环境下使用SSH的开源图形化SFTP客户端.同时支持S ...
- EPPlus批量插入图片到Excel
#region 测试EPPlus插入图片 public static void Createsheel2() { WebClien ...
- EWS 流通知订阅邮件
摘要 查找一些关于流通知订阅邮件的资料,这里整理一下. 核心代码块 using System; using System.Collections.Generic; using System.Linq; ...