android SwipeRefreshLayout google官方下拉刷新控件
下拉刷新功能之前一直使用的是XlistView很方便我前面的博客有介绍
SwipeRefreshLayout是google官方推出的下拉刷新控件使用方法也比较简单
今天就来使用下SwipeRefreshLayout 以后再需要时可以参考.
首先在布局里面加入SwipeRefreshLayout 布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swiperefreshlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"> <ListView
android:id="@+id/tab_topical_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" /> </android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
Activity文件中的代码
mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swiperefreshlayout);
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorRed , R.color.colorGre , R.color.colorBlu);
mSwipeRefreshLayout.setProgressViewEndTarget(true , 150);
mSwipeRefreshLayout.setOnRefreshListener(this);
使用setColorSchemeResources设置下拉刷新的图标颜色可设置四种颜色.
setProgressViewEndTarget(true , 150)设置距离顶端的距离
setOnRefreshListener(this)设置监听
监听方法:
//滑动手势监听 , 加载数据
@Override
public void onRefresh() {
Toast.makeText(getActivity() , "loding..." , Toast.LENGTH_SHORT).show();
getDate();//获取数据
mSwipeRefreshLayout.setRefreshing(false);
}
搞定了上面两步就可以使用SwipeRefreshLayout这个控件了.
看下效果:

很简单吧.
android SwipeRefreshLayout google官方下拉刷新控件的更多相关文章
- 第一个开源控件:Google 官方下拉刷新控件 SwipeRefreshLayout 强化版,支持上拉刷新
最近比较闲,所以趁着这时间撸了个SwipeRefreshLayout的加强版,Github地址. 原版只支持下拉刷新,强化之后支持上拉刷新和一进入页面就加载刷新,整个控件的加载动画是一致的,毫无违和感 ...
- Android SwipeRefreshLayout 官方下拉刷新控件介绍
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/24521483 下面App基本都有下拉刷新的功能,以前基本都使用XListView ...
- Google SwipeRefreshLayout(Goolge官方下拉刷新控件)尝鲜
前天Google官方终于出了Android刷新控件——SwipeRefreshLayout. 使用前先需要将android.support.v4.jar升级到19.1.升级后,可能会出现SDK版本与A ...
- 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 ...
- Android之官方下拉刷新控件SwipeRefreshLayout
SwipeRefreshLayout 是在V4包里面,首先要先导入V4包,最新的V4包里面才有这控件 首先是布局 <android.support.v4.widget.SwipeRefreshL ...
- Android PullToRefresh下拉刷新控件的简单使用
PullToRefresh这个开源库早就听说了,不过一直没用过.作为一个经典的的开源库,我觉得还是有必要认识一下. 打开github上的网址:https://github.com/chrisbanes ...
随机推荐
- [转]jQuery: how to get which button was clicked upon form submission?
本文转自:http://stackoverflow.com/questions/5721724/jquery-how-to-get-which-button-was-clicked-upon-form ...
- [转]how to split the ng-repeat data with three columns using bootstrap
本文转自:http://stackoverflow.com/questions/21644493/how-to-split-the-ng-repeat-data-with-three-columns- ...
- git 学习使用总结二(远程仓库操作)
这篇文章仅供自己以后翻阅加深记忆,要系统的学习 git 教程(中文版),请移步到 liaoxuefeng.com 学习 git 教程部分. 我使用的是 windows 系统,所以使用 Git Bash ...
- RCC BUCK-BOOST变压器设计
电路处于Buck-Boost DCM模式,最恶劣情况为输入电压最低时.取频率为f 以下图为例: 1.MOS耐压选择: Vmos≥Vinmax+Vout+80 2.保证磁芯不饱和且始终工作在DCM模式 ...
- Network Experiment Environment Construction
In order to provide an environment for network experiments in the future, I use VirutalBox to create ...
- CSS样式----图文详解(二):css属性
主要内容 CSS的单位 字体属性 文本属性 背景属性 列表属性 盒子模型 定位属性:position.float.overflow.z-index等 导航栏的制作 鼠标的属性cursor 滤镜的介绍 ...
- NOIP2003神经网络[BFS]
题目背景 人工神经网络(Artificial Neural Network)是一种新兴的具有自我学习能力的计算系统,在模式识别.函数逼近及贷款风险评估等诸多领域有广泛的应用.对神经网络的研究一直是当今 ...
- AC日记——输出亲朋字符串 openjudge 1.7 05
05:输出亲朋字符串 总时间限制: 1000ms 内存限制: 65536kB 描述 编写程序,求给定字符串s的亲朋字符串s1. 亲朋字符串s1定义如下:给定字符串s的第一个字符的ASCII值加第二 ...
- [技巧] 解决Win7下VMware中vmx86.sys报错的问题
电梯直达 1楼 发表于 2012-7-2 15:14:22||倒序浏览|阅读模式 .pcb { margin-right: 0 } 当以普通用户权限运行的时候,VMware便会如此报错"无法 ...
- Eclipse C++开发环境配置(很简洁)
from: https://www.zybuluo.com/ghostfn1/note/303921