最简单下拉刷新,Google最新(可刷新任何控件)
2014-04-06 23:10
405 查看
http://www.eoeandroid.com/thread-328133-1-1.html
Google终于出下拉刷新控件了,你们知道吗?
2014年3月29日
XML文件需要引用android.support.v4.widget.SwipeRefreshLayout控件,在里面可以放置任何一个控件,包括ListView,scrollview,gridview等等,。都可以下拉刷新。。。。。。
main_activity.xml代码:
<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/list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
MainActivity.java
/*
* Created by Storm Zhang, Mar 31, 2014.
*/
package com.storm.swiperefreshlayoutdemo;
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.ListView;
public class MainActivity extends Activity implements SwipeRefreshLayout.OnRefreshListener {
private SwipeRefreshLayout swipeLayout;
private ListView listView;
private ListViewAdapter adapter;
private ArrayList<SoftwareClassificationInfo> list;
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
swipeLayout.setOnRefreshListener(this);
swipeLayout.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light,
android.R.color.holo_orange_light, android.R.color.holo_red_light);
list = new ArrayList<SoftwareClassificationInfo>();
list.add(new SoftwareClassificationInfo(1, "asdas"));
listView = (ListView) findViewById(R.id.list);
adapter = new ListViewAdapter(this, list);
listView.setAdapter(adapter);
}
@override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
public void run() {
swipeLayout.setRefreshing(false);
list.add(new SoftwareClassificationInfo(2, "ass"));
adapter.notifyDataSetChanged();
}
}, 1000);
}
}
Demo如下,感谢大家支持。
Google终于出下拉刷新控件了,你们知道吗?
2014年3月29日
XML文件需要引用android.support.v4.widget.SwipeRefreshLayout控件,在里面可以放置任何一个控件,包括ListView,scrollview,gridview等等,。都可以下拉刷新。。。。。。
main_activity.xml代码:
<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/list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
MainActivity.java
/*
* Created by Storm Zhang, Mar 31, 2014.
*/
package com.storm.swiperefreshlayoutdemo;
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.ListView;
public class MainActivity extends Activity implements SwipeRefreshLayout.OnRefreshListener {
private SwipeRefreshLayout swipeLayout;
private ListView listView;
private ListViewAdapter adapter;
private ArrayList<SoftwareClassificationInfo> list;
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
swipeLayout.setOnRefreshListener(this);
swipeLayout.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light,
android.R.color.holo_orange_light, android.R.color.holo_red_light);
list = new ArrayList<SoftwareClassificationInfo>();
list.add(new SoftwareClassificationInfo(1, "asdas"));
listView = (ListView) findViewById(R.id.list);
adapter = new ListViewAdapter(this, list);
listView.setAdapter(adapter);
}
@override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
public void run() {
swipeLayout.setRefreshing(false);
list.add(new SoftwareClassificationInfo(2, "ass"));
adapter.notifyDataSetChanged();
}
}, 1000);
}
}
Demo如下,感谢大家支持。
相关文章推荐
- 最简单下拉刷新,Google最新(可刷新任何控件)
- 最简单下拉刷新,Google最新(可刷新任何控件)
- android —— 自定义控件 最简单下拉刷新,Google最新(可刷新任何控件)
- 学习google最新下拉刷新控件SwipeRefreshLayout
- 第一个开源控件:Google官方下拉刷新控件SwipeRefreshLayout强化版,支持上拉刷新
- PullToRefreshListView上拉加载,下拉刷新 刷新网络数据 简单实现ListView显示网络数据
- 简单使用android自带刷新控件SwipeRefreshLayout
- Google自己的下拉刷新组件 SwipeRefreshLayout + RecyclerView 实现 上拉刷新 和 下拉刷新
- Android进阶之路 - Google下最简单的下拉刷新(SwipeRefreshLayout)
- google官方提供的 SwipeRefreshLayout 下拉刷新的简单实用
- cocos2d-x Jni c++ java互调 安全刷新UI控件最简单例子(上)
- 用google官方控件SwipeRefreshLayout实现RecyclerView的下拉刷新和上拉加载
- Android开发丶谷歌官方刷新控件SwipeRefreshLayout下拉刷新的实现和上拉加载的拓展
- Google原生下拉刷新控件 SwipeRefreshLayout
- 实现Google应用最新的下拉刷新效果
- Google Maps API 2.0解析(17-GSmallMapControl和GSmallZoomControl两个简单的控件)
- 一步步自定义下拉刷新上拉加载——自定义简单的刷新组件
- Android仿苹果版QQ下拉刷新实现(一) ——打造简单平滑的通用下拉刷新控件
- 分享一个简单好用的下拉刷新、上拉加载控件