不只是pulltorefresh才可以下拉刷新
来源:互联网 发布:手机淘宝账号怎么查看 编辑:程序博客网 时间:2024/06/09 18:50
开源项目pull-to-refresh比较火热,可实现各种形式的下拉刷新,然而使用该项目你就不得不引入他的库文件留配合使用。那么有没有一种原生支持的下拉刷新来满足这个懒惰程序元的愿望呢,答案被找到了:官方的组件---SwipeRefreshLayout,
简介:SwipeRefreshLayout是Google在support v4 19.1版本的library更新的一个下拉刷新组件,使用起来很方便,可以很方便的实现Google Now的刷新效果。使用官方自带的控件能够保证通用性以及风格。SwipeRefreshLayout是继承ViewGroup,来实现下拉刷新,它可以包含其他组件,亲测listview、gridview、scrollview可用,可能还包括更多。。。。。。
不得不说,使用起来非常的简单
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context="com.example.myapplication2.app.MainActivity"> <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swip" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="match_parent"> </ListView> </android.support.v4.widget.SwipeRefreshLayout></RelativeLayout>你只需要做的就是引入v4包就可以了
android.support.v4.widget.SwipeRefreshLayout
程序实现代码:
swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.listview);//旋转三色swipeRefreshLayout.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);swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {@Overridepublic void onRefresh() {new Handler().postDelayed(new Runnable() {@Overridepublic void run() {//刷新数据ToastUtils.show(getActivity(),"sfq-=debug-refresh");swipeRefreshLayout.setRefreshing(false);}}, 1000);}});
swipeRefreshLayout.setRefreshing(false)这句话是关掉数显效果。
OK,绝对的简单粗暴!!
1 0
- 不只是pulltorefresh才可以下拉刷新
- android pulltorefresh 下拉刷新
- PullToRefresh 下拉刷新菜单
- PullToRefresh下拉刷新
- PullToRefresh下拉刷新框架
- PullToRefresh的下拉刷新
- android控件 下拉刷新pulltorefresh
- PullToRefresh 针对SrcollView 下拉刷新
- android 之 下拉刷新PullToRefresh
- pulltorefresh:QQ下拉刷新应用
- 下拉刷新--第三方开源--PullToRefresh
- 修改PullToRefresh下拉刷新动画
- 下拉刷新--第三方开源--PullToRefresh
- ListView下拉刷新(PullToRefresh)
- PullToRefresh(下拉刷新)源码浅析
- android Android-PullToRefresh 下拉刷新
- 168_下拉刷新PullToRefresh
- PullToRefresh下拉刷新使用详解
- 可变数组NSMutableArray详解
- Scala中类的继承,超类的重载等
- Linux串口编程详解
- 关于html中li的问题
- 如何在Mac上配置/使用Github
- 不只是pulltorefresh才可以下拉刷新
- ESX6如何实现开机登录的界面
- C++中的函数指针和函数对象
- CocurrentHashMap和Hashtable的区别
- 4. 正则表达式(4)
- git@osc使用教程
- gdb之core
- 零基础学python-7.7 字符串格式化方法(2)
- 验证控件