项目地址:Android-PullRefreshLayout
简介:基于SwipeRefreshLayout,通吃所有的AbsListView、RecyclerView
基于SwipeRefreshLayout下拉刷新、上拉加载。支持所有的AbsListView、RecycleView
仔细看listSelector属性,效果见sample
<com.mylhyl.prlayout.SwipeRefreshListView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/swipeRefresh" android:layout_width="match_parent" android:layout_height="match_parent" android:listSelector="@drawable/selector_list" tools:context=".app.ListViewXmlFragment" />设置上拉加载,更多方法见 IFooterLayout
IFooterLayout footerLayout = swipeRefreshListView.getFooterLayout(); footerLayout.setFooterText("set 自定义加载"); footerLayout.setIndeterminateDrawable(getResources().getDrawable(R.drawable.footer_progressbar));或
pr:footer_text="数据正在加载中" pr:footer_indeterminate_drawable="@drawable/footer_progressbar"自定义上拉加载
方式一:注意此方法必须在setOnListLoadListener之前调用 getSwipeRefreshLayout().setFooterResource(R.layout.swipe_refresh_footer); 方式二:xml 属性 pr:footer_layout="@layout/swipe_refresh_footer" 方式三:继承重写getFooterResource()方法 public class MySwipeRefreshGridView extends SwipeRefreshGridView { @Override protected int getFooterResource() { return R.layout.swipe_refresh_footer; } }设置 adapter 空数据视图文字
swipeRefreshListView.setEmptyText("数据呢?");自定义 adapter 空数据视图
ImageView emptyView = new ImageView(getContext()); emptyView.setImageResource(R.mipmap.empty); swipeRefreshGridView.setEmptyView(emptyView);调用autoRefresh自动刷新,那么注册ListView长按事件怎么办?好办提供了方法getScrollView()取出 又有问题了既然能取到ListView那SwipeRefreshLayout是不是也可以取到呢? 答案是肯定的,方法getSwipeRefreshLayout取出,你可以随心所欲了,设置下拉圆圈的颜色、大小等。 关于更多公开方法见ISwipeRefresh
但是由于jar不能打包res原因,将影响xml属性的使用,手动拷贝attrs到自己的项目中. 也可以clone源码,然后在 eclipse 中用library方式引用