1、Android自己的下拉刷新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" >
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp" />
</android.support.v4.widget.SwipeRefreshLayout
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
import android.widget.ArrayAdapter;
import android.widget.ListView; public class MainActivity extends Activity implements
SwipeRefreshLayout.OnRefreshListener { private SwipeRefreshLayout mSwipeLayout;
private ListView mListView;
private ArrayList<String> list = new ArrayList<String>(); protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); mListView = (ListView) findViewById(R.id.listview);
mListView.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
getData())
); 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);
} private ArrayList<String> getData() {
list.add("Hello");
list.add("This is stormzhang");
list.add("An Android Developer");
list.add("Love Open Source");
list.add("My GitHub: stormzhang");
list.add("weibo: googdev");
return list;
} public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mSwipeLayout.setRefreshing(false);
}
}, 5000);
}
}
1、Android自己的下拉刷新SwipeRefreshLayout的更多相关文章
- android自带下拉刷新SwipeRefreshLayout
也是一个布局容器,只有一个子组件,类似scrollView <?xml version="1.0" encoding="utf-8"?> <a ...
- Android Material Design控件使用(四)——下拉刷新 SwipeRefreshLayout
使用下拉刷新SwipeRefreshLayout 说明 SwipeRefreshLayout是Android官方的一个下拉刷新控件,一般我们使用此布局和一个RecyclerView嵌套使用 使用 xm ...
- Android listview下拉刷新 SwipeRefreshLayout
今天在Google+上看到了SwipeRefreshLayout这个名词,遂搜索了下,发现竟然是刚刚google更新sdk新增加的一个widget,于是赶紧抢先体验学习下. SwipeRefreshL ...
- Android下拉刷新-SwipeRefreshLayout,RecyclerView完全解析之下拉刷新与上拉加载SwipeRefreshLayout)
SwipeRefrshLayout是Google官方更新的一个Widget,可以实现下拉刷新的效果.该控件集成自ViewGroup在support-v4兼容包下,不过我们需要升级supportlibr ...
- Android内置下拉刷新组件SwipeRefreshLayout
也许下拉刷新之前,你可能会使用一些第三方的开源库,例如PullToRefresh, ActionBar-PullToRefresh等待,但现在有的正式组成部分---SwipeRefreshLayout ...
- Android下拉刷新-SwipeRefreshLayout
现在市面上新闻类的App基本上都有下拉刷新,算是一个标配吧,网上关于下拉刷新的博客也有很多,实现方式可以使用开源的PullToRefresh,自定义ListView,或者可以直接使用LineLayOu ...
- Android原生下拉刷新SwipeRefreshLayout实践
本篇文章翻译自Ravi Tamada的Android Swipe Down to Refresh ListView Tutorial 首先来看一下效果图 你应该发现很多的android app比如Tw ...
- Android——谷歌官方下拉刷新控件SwipeRefreshLayout(转)
转自:http://blog.csdn.net/zouzhigang96/article/details/50476402 版权声明:本文为博主原创文章,未经博主允许不得转载. 前言: 如今谷歌推出了 ...
- Android下拉刷新SwipeRefreshLayout简单用法
之前一直都想用下拉刷新,感觉上是庞大的工程,所以搁置了.现在学习了一下其实真的超级简单. 看了<第一行代码>以及 https://www.jianshu.com/p/3c402a9e4b7 ...
随机推荐
- IDEA启动服务慢的问题处理
问题描述: 微服务模式下统一启动服务,很慢如下图: 这种情况是IDEA工作环境有问题. 解决方法: 从SVN或者Git重新检出项目,即可解决.
- openstack neutron L3 HA
作者:Liping Mao 发表于:2014-08-20 版权声明:能够随意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 近期Assaf Muller写了一篇关于Neutro ...
- Maven打jar包的三种方式
Maven打jar包的三种方式 不包含依赖jar包 该方法打包的jar,不包含依赖的jar包,也没有指定入口类. <build> <plugins> <plugin> ...
- Event-Souring模式
Event-Sourcing模式使用仅附加存储来记录或描写叙述域中数据所採取的动作,从而记录完整的一系列系列事件,而不是仅存储实体的当前状态.由于存储包括全部的事件,能够用来具体化域对象. Event ...
- Atitit.vod 视频播放系统 影吧系统的架构图 架构体系 解决方案
Atitit.vod 视频播放系统 影吧系统的架构图 架构体系 解决方案 1. 运行平台:跨平台 android ios pc mobile 1.1. -------------前端 界面------ ...
- atitit. it软件项目管理---自己的员工,雇佣军、援军,混合的员工 杂牌 人员管理架构
atitit. it软件项目管理---自己的员工,雇佣军.援军,混合的员工 杂牌 人员管理架构 1. 企业的正规军,雇佣军,杂牌划分 1 1.1. 企业的员工基本是雇佣而来 1 1.2. 全职员工与兼 ...
- RS232接口
想用下板子,却发现板子和USB转串口线都是母口,无耐只能自己用线将对应的管脚连起来. 结果测试的时候发现,板子能发不能收.将板子串口的23连起来,回环正常.电脑USB转串口线上的23连起来也回环正常. ...
- [elk]logstash grok原理
logstash语法 http://www.ttlsa.com/elk/elk-logstash-configuration-syntax/ https://www.elastic.co/guide/ ...
- Myeclipse中 Exploded location overlaps an existing deployment解决办法
实效解决方法: 项目->properties->MyEclipse->Web->Web Context-root的名字为重命名之后的名字即可 其实这里的Web Context- ...
- 新标准C++程序设计读书笔记_运算符重载
形式 返回值类型 operator 运算符(形参表) { …… } 运算符重载 (1)运算符重载的实质是函数重载(2)可以重载为普通函数,也可以重载为成员函数 class Complex { publ ...