SwipeRefreshLayout是V4包下的一个组件,老版本的V4包不支持这个组件功能。因此,如果发现自己的项目中无法导入SwipeRefreshLayout的包,那么说明项目中的V4包是老版本的,需要更新才可以。

我这里下拉刷新是配合ListView来完成的。请看布局:

 <android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/mRefreshLayout"
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"
android:animationCache="false"
android:dividerHeight="0dp"
android:listSelector="#00000000"
android:scrollingCache="false"
android:smoothScrollbar="true" />
</android.support.v4.widget.SwipeRefreshLayout>

接下来实在代码中实现:

private SwipeRefreshLayout mRefreshLayout;// SwipeRefreshLayout下拉刷新控件
mRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.mRefreshLayout);
// 下拉刷新颜色控制
mRefreshLayout.setColorSchemeResources(R.color.swiperefresh_color1,
R.color.swiperefresh_color2, R.color.swiperefresh_color3,
R.color.swiperefresh_color4);
    mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {             @Override
            public void onRefresh() {
                // 启动刷新的控件
                mRefreshLayout.post(new Runnable() {
                    @Override
                    public void run() {
                        // 设置是否开始刷新,true为刷新,false为停止刷新
                        mRefreshLayout.setRefreshing(true);                     }
                });
            }
        });
//停止刷新
mRefreshLayout.setRefreshing(false);

最新文章

  1. SILVERLIGHT 应急卫生模拟演练项目之childwindow
  2. 一起买beta版UI测试
  3. Shape + Selector: Make a Shape as one item of the Selector
  4. 【翻译十九】-java之执行器
  5. 快乐的JS正则表达式(二)
  6. SeekableByteChannel 和 FileChannel
  7. HDU 4334 Trouble (暴力)
  8. 详解 Qt 线程间共享数据(用信号槽方式)
  9. log4net使用简明教程
  10. [原]Unity3D深入浅出 - 物理引擎之碰撞体(Colliders)
  11. svn出错错误
  12. js进制转换
  13. KestrelServer
  14. NEU OJ 1649 GMZ’s Pretty Number
  15. Lists, Maps and Sets in Java
  16. 版本12.2.0.1.0数据库,复制种子数据库快速创建租户数据库PDB
  17. 复习python(条件判断、循环、字符串格式化)
  18. 自学Linux命令行与Shell脚本之路
  19. 在django中,执行原始sql语句
  20. python-模板方法模式

热门文章

  1. 17.struts-开发流程.md
  2. 让Source Insight完美支持中文注释
  3. js基础-函数基础
  4. R语言-画散点图
  5. Android Studio 2.3.3上引入3.0上开发的项目遇到的问题
  6. spring 事务传播
  7. msf客户端渗透(五):注册表
  8. spring 中 PO与DTO相互转换的工具类
  9. BeautifulSoup中查找元素 select() 和find()区别
  10. python--第二天总结