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" >    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;@overrideprotected 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);}@overridepublic void onRefresh() {             new Handler().postDelayed(new Runnable() {             public void run() {                          swipeLayout.setRefreshing(false);                          list.add(new SoftwareClassificationInfo(2, "ass"));                          adapter.notifyDataSetChanged();              }             }, 1000);            }}



Demo如下,感谢大家支持。



Google 下载地址: Demon下载请点击这里

110023izlpdpesua6jhawd[1].jpg(513.43 KB, 下载次数: 22)

更多相关文章

  1. android游戏开发项目实战——数独
  2. ch017 Android(安卓)样式与主题
  3. android Activity 变成Dialog的方法
  4. ch017 Android(安卓)样式与主题
  5. 引用 Android内核和驱动篇-Android内核介绍
  6. Android(安卓)Launcher一些资源
  7. android:maxLines和android:ellipsize
  8. android 解决password过时
  9. android:ellipsize的使用

随机推荐

  1. 关于Android(安卓)SQLite3多线程并发问题
  2. android 内存分析工具--001
  3. Android(安卓)Studio 奇技淫巧
  4. Android常用固件修改
  5. 在Mac下编译Android源码
  6. startService与bindService的区别
  7. Android(安卓)NDK开发 环境搭建
  8. android之DEX文件格式
  9. Android通话默认打开扬声器的方法
  10. Android和Js交互及WebView优化