V4的兼容包

API

大概就这4个常用的方法。

code

布局

<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"
tools:context=".MainActivity" > <android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="match_parent" > <ListView
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.SwipeRefreshLayout> </RelativeLayout>

MainActivty

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = (ListView) findViewById(R.id.listview);
mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe); list = new ArrayList<MyTextClass>(); Map<String, String> maps = new HashMap<String, String>();
maps.put("1", "2"); myHandler = new MyHandler(); client = new MyHttpClient(myHandler); myThread = new MyThread(client,"http://192.168.1.4/json/index.php",maps,GETJSON); myHandler.setThread(myThread); myHandler.setHandlerExtraHandleMessage(new MyHandler.HandlerExtraHandleMessage()
{ @Override
public void handleMessage(Message msg) {
switch (msg.what) {
case GETJSON:
String strJson1 = (String) msg.obj;
Json json1 = new Json(strJson1);
try {
list = json1.getMyTextClass();
} catch (JSONException e) {
e.printStackTrace();
}
myBaseAdapter = new MyBaseAdapter(MainActivity.this, list);
listView.setAdapter(myBaseAdapter);
break;
case REFRESH:
String strJson2 = (String) msg.obj;
Json json2 = new Json(strJson2);
//list.clear();
try {
list = json2.getMyTextClass();
} catch (JSONException e) {
e.printStackTrace();
} if(myBaseAdapter != null)
{
myBaseAdapter.setList(list);
myBaseAdapter.notifyDataSetChanged();
}
else
{
MyBaseAdapter myBaseAdapter2 = new MyBaseAdapter(MainActivity.this, list);
listView.setAdapter(myBaseAdapter2);
}
mSwipeLayout.setRefreshing(false);
break; default:
System.out.println("Other Message");
break;
}
super.handleMessage(msg);
} }); Map<String, String> maps2 = new HashMap<String, String>();
maps.put("1", "2");
MyRefreshListener myRefreshListener = new MyRefreshListener(myHandler, maps2, REFRESH);
mSwipeLayout.setOnRefreshListener(myRefreshListener);
mSwipeLayout.setColorScheme(android.R.color.holo_green_dark, android.R.color.holo_green_light,
android.R.color.holo_orange_light, android.R.color.holo_red_light); }

我是天王盖地虎的分割线

源代码:http://pan.baidu.com/s/1dD1Qx01

listview异步.zip

 

Android -- 官方下拉刷新SwipeRefreshLayout的更多相关文章

  1. Android 官方下拉刷新 SwipeRefreshLayout

    0.build.gradle compile 'com.android.support:support-v4:23+' 1.布局文件 <android.support.v4.widget.Swi ...

  2. android官方下拉刷新控件SwipeRefreshLayout的使用

    可能开发安卓的人大多数都用过很多下拉刷新的开源组件,但是今天用了官方v4支持包的SwipeRefreshLayout觉得效果也蛮不错的,特拿出来分享. 简介:SwipeRefreshLayout组件只 ...

  3. 【转】Android官方下拉刷新控件 SwipeRefreshLayout

    今天在Google+上看到了SwipeRefreshLayout这个名词,遂搜索了下,发现竟然是刚刚google更新sdk新增加的一个widget,于是赶紧抢先体验学习下. SwipeRefreshL ...

  4. android——官方下拉刷新组件SwipeRefreshLayout(转)

    一.问题描述 在android开发中,使用最多的数据刷新方式就是下拉刷新了,而完成此功能我们使用最多的就是第三方的开源库PullToRefresh.现如今,google也忍不住推出了自己的下拉组件Sw ...

  5. Android listview下拉刷新 SwipeRefreshLayout

    今天在Google+上看到了SwipeRefreshLayout这个名词,遂搜索了下,发现竟然是刚刚google更新sdk新增加的一个widget,于是赶紧抢先体验学习下. SwipeRefreshL ...

  6. Android原生下拉刷新SwipeRefreshLayout实践

    本篇文章翻译自Ravi Tamada的Android Swipe Down to Refresh ListView Tutorial 首先来看一下效果图 你应该发现很多的android app比如Tw ...

  7. Android Material Design控件使用(四)——下拉刷新 SwipeRefreshLayout

    使用下拉刷新SwipeRefreshLayout 说明 SwipeRefreshLayout是Android官方的一个下拉刷新控件,一般我们使用此布局和一个RecyclerView嵌套使用 使用 xm ...

  8. Android智能下拉刷新加载框架—看这些就够了

    一些值得学习的几个下拉刷新上拉加载开源库 Android智能下拉刷新框架-SmartRefreshLayout 支持所有的 View(AbsListView.RecyclerView.WebView. ...

  9. Xamarin. Android实现下拉刷新功能

    PS:发现文章被其他网站或者博客抓取后发表为原创了,给图片加了个水印 下拉刷新功能在安卓和iOS中非常常见,一般实现这样的功能都是直接使用第三方的库,网上能找到很多这样的开源库.然而在Xamarin. ...

随机推荐

  1. yii2源码学习笔记(六)

    Behvaior类,Behavior类是所有事件类的基类: 目录yii2\base\Behavior.php <?php /** * @link http://www.yiiframework. ...

  2. input里面的查找标记 ő

    <i id="J_SearchIcon" class="iconfont">ő</i> .iconfont {ont-family: i ...

  3. spoj 2319 BIGSEQ - Sequence

    You are given the sequence of all K-digit binary numbers: 0, 1,..., 2K-1. You need to fully partitio ...

  4. gcc链接g++编译生成的静态库和动态库的makefile示例

    使用c++开发程序或者库时,将库提供给其他人使用. 然而使用者是使用c开发的程序,链接g++编译生成的库时,于链接gcc生成的库,有所不同. 首先是静态库,以链接g++编译生成的libmylib.a为 ...

  5. [待续]Async in C# 1

    异步.异步是在.net .45里面提供的一个新的方法 它主要用在.三个方面 1.网络访问 2.磁盘访问 3.延迟很长时间的步骤 它主要有2个关键字 Async  Await Async  怎么工作 d ...

  6. runAllManagedModulesForAllRequests 和 invalid url

    有这样的经验, 在本地的 IIS 上网站运行正常,但是发布到服务器上就一堆怪怪的问题 : MVC routing not work http://stackoverflow.com/questions ...

  7. 再来,LVS+KEEPALIVED

    记得常规组合哟. 一般同时实现HA+LB. 如果只需要实现一个,那还不如UCARP?双机绑定一个IP作热备. CENTOS6:PACEMAKER+COROSYNC+HAPROXY. OTHER:HEA ...

  8. zz将 VSTO 插件部署给所有用户

    原文:zz将 VSTO 插件部署给所有用户 注:本文原作者 Misha Shneerson 是 VSTO 团队的工程师.原文可以在下列地址找到:http://blogs.msdn.com/mshnee ...

  9. 浅度围观SBJson

    JSON JSON是一种取代XML的数据结构,和xml相比,它更小巧但描述能力却不差,由于它的小巧所以网络传输数据将减少更多流量从而加快速度, 那么,JSON到底是什么? JSON就是一串字符串 只不 ...

  10. 数据结构(线段树):SPOJ GSS3 - Can you answer these queries III

    GSS3 - Can you answer these queries III You are given a sequence A of N (N <= 50000) integers bet ...