Skip to content

Commit 547a534

Browse files
committed
readme
1 parent 44302c7 commit 547a534

File tree

1 file changed

+91
-9
lines changed

1 file changed

+91
-9
lines changed

README.md

Lines changed: 91 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
![Screenshot](https://github.com/HomHomLin/Android-PullToRefreshRecyclerView/blob/master/screenshot.gif)
44

5-
这是一个可以下拉刷新的RecyclerView,并且支持方便添加Header、滑动到底部自动加载更多以及其他ListView的功能。
5+
这是一个可以下拉刷新的RecyclerView,并且支持方便添加Header、滑动到底部自动加载更多以及其他ListView的功能,可以帮助你在RecyclerView里实现ListView拥有但RecyclerView没有的功能
66

7-
当前版本:v1.0.0
7+
**Latest version:v1.0.0**
88

9-
## 特性
9+
## Feature
1010
* 基于原生RecyclerView的封装
1111
* 支持下拉刷新
1212
* 支持滑动到底部自动加载更多
@@ -17,17 +17,99 @@
1717
* **LinearLayoutManager**
1818
* **GridLayoutManager**
1919

20-
项目位置<https://github.com/HomHomLin/Android-PullToRefreshRecyclerView>.
20+
Project site<https://github.com/HomHomLin/Android-PullToRefreshRecyclerView>.
2121

2222
## Sample
23-
项目内含有Sample程序:[Sample](https://github.com/HomHomLin/Android-PullToRefreshRecyclerView/blob/master/sample.apk)
23+
There has a Sample in project:[Sample](https://github.com/HomHomLin/Android-PullToRefreshRecyclerView/blob/master/sample.apk)
2424

2525
##Using library in your application
26-
If you are building with Gradle, simply add the following line to the dependencies section of your build.gradle file:
2726

28-
dependencies {
29-
compile 'homhomlin.lib:ptrrv-library:1.0.0'
30-
}
27+
**Gradle dependency:**
28+
``` groovy
29+
compile 'homhomlin.lib:ptrrv-library:1.0.0'
30+
```
31+
32+
or
33+
34+
**Maven dependency:**
35+
``` xml
36+
<dependency>
37+
<groupId>homhomlin.lib</groupId>
38+
<artifactId>ptrrv-library</artifactId>
39+
<version>1.0.0</version>
40+
</dependency>
41+
```
42+
43+
##Usage
44+
45+
PullToRefreshRecyclerView is easy to use just like ListView and RecyclerView.
46+
47+
**First: Config in xml**
48+
``` xml
49+
<?xml version="1.0" encoding="utf-8"?>
50+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
51+
android:layout_width="match_parent"
52+
android:layout_height="match_parent">
53+
54+
<com.lhh.ptrrv.library.PullToRefreshRecyclerView
55+
android:id="@+id/ptrrv"
56+
android:layout_width="match_parent"
57+
android:layout_height="match_parent"/>
58+
59+
</RelativeLayout>
60+
```
61+
62+
**Second: Find it in your Activity**
63+
``` java
64+
PullToRefreshRecyclerView mPtrrv = (PullToRefreshRecyclerView) this.findViewById(R.id.ptrrv);
65+
```
66+
67+
**Third: Config it in java code**
68+
``` java
69+
// set true to open swipe(pull to refresh, default is true)
70+
mPtrrv.setSwipeEnable(true);
71+
72+
// set the layoutManager which to use
73+
mPtrrv.setLayoutManager(new LinearLayoutManager(this));
74+
75+
// set PagingableListener
76+
mPtrrv.setPagingableListener(new PullToRefreshRecyclerView.PagingableListener() {
77+
@Override
78+
public void onLoadMoreItems() {
79+
//do loadmore here
80+
}
81+
});
82+
83+
// set OnRefreshListener
84+
mPtrrv.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
85+
@Override
86+
public void onRefresh() {
87+
// do refresh here
88+
}
89+
});
90+
91+
// add item divider to recyclerView
92+
mPtrrv.getRecyclerView().addItemDecoration(new DividerItemDecoration(this,
93+
DividerItemDecoration.VERTICAL_LIST));
94+
95+
// add headerView
96+
mPtrrv.addHeaderView(View.inflate(this, R.layout.header, null));
97+
98+
//set EmptyVIEW
99+
mPtrrv.setEmptyView(View.inflat(this,R.layout.empty_view, null));
100+
101+
// set loadmore String
102+
mPtrrv.setLoadmoreString("loading");
103+
104+
// set loadmore enable, onFinishLoading(can load more? , select before item)
105+
mPtrrv.onFinishLoading(true, false);
106+
```
107+
108+
**Finally: Set the adapter which extends RecyclerView.Adpater**
109+
``` java
110+
PtrrvAdapter mAdapter = new PtrrvAdapter(this);
111+
mPtrrv.setAdapter(mAdapter);
112+
```
31113

32114
##License
33115
Copyright 2015 LinHongHong

0 commit comments

Comments
 (0)