Created
July 26, 2018 16:12
-
-
Save gbzarelli/f55bc5926651edc496ee375a0a97105c to your computer and use it in GitHub Desktop.
SwipeRefreshLayout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected SwipeRefreshLayout swipe; | |
swipe = layout.findViewById(swipeId); | |
swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { | |
@Override | |
public void onRefresh() { | |
sendRequest(); | |
} | |
}); | |
protected void showProgress() { | |
swipe.post(new Runnable() { | |
@Override | |
public void run() { | |
swipe.setRefreshing(true); | |
} | |
}); | |
} | |
protected void stopRequest() { | |
swipe.postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
swipe.setRefreshing(false); | |
} | |
}, 1000); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<android.support.v4.widget.SwipeRefreshLayout | |
android:id="@+id/swiperefresh" | |
android:layout_width="match_parent" | |
android:layout_height="0dp" | |
android:layout_weight="1"> | |
<android.support.v7.widget.RecyclerView | |
android:id="@+id/recyclerview" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_marginLeft="16dp" | |
android:layout_marginRight="16dp" | |
android:scrollbars="vertical" | |
app:layoutManager="LinearLayoutManager" /> | |
</android.support.v4.widget.SwipeRefreshLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment