From 7eaeea0f87a56c8c0d6f46663f2ff35c772fe79b Mon Sep 17 00:00:00 2001 From: Ingo Schwarz Date: Sat, 8 Oct 2016 14:55:41 +0200 Subject: [PATCH] Create Swipe to Refresh section in Readme --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index a5e233f..71f1263 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,22 @@ If you want to have a seperator between the data rows you can do so by specifyin ``` As for the `ListView` you can specify `divider` as a drawable and `dividerHeight` as the vertical size of the divider. +### Swipe to Refresh +The TableView has a build in SwipeToRefresh action. By default this is disabled, but you can easily enable it using the follwing line. +```java + tableView.setSwipeToRefreshEnabled( true ); +``` +This enables the user to trigger the table refresh on a single swipe. To listen for this user interaction you have to set an `SwipeToRefreshListener` to your tableview. +```java + carTableView.setSwipeToRefreshListener(new SwipeToRefreshListener() { + @Override + public void onRefresh(final RefreshIndicator refreshIndicator) { + // your async refresh action goes here + } + }); +``` +The callback method has the `RefreshIndicator` that is shown to the user passed as parameter. So if you finished your refresh action simply call `RefreshIndicator.hide()`. + ### State Persistence The TableView as well as the SortableTableView will persist its state automatically (e.g. on orientation change). If you want to disable this behaviour you can do so using the following code snipped. ```java