Created
April 24, 2015 02:03
-
-
Save djyde/c12a9e4d9cda66516b2a to your computer and use it in GitHub Desktop.
触底加载
This file contains 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
list.setOnScrollListener(new RecyclerView.OnScrollListener() { | |
@Override | |
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | |
visibleItemCount = layoutManager.getChildCount(); | |
totalItemCount = layoutManager.getItemCount(); | |
pastItems = layoutManager.findFirstVisibleItemPosition(); | |
if (!onLoading) { | |
if ((pastItems + visibleItemCount) >= totalItemCount) { | |
Toast.makeText(getApplicationContext(),"loading...",SHORT).show(); | |
onLoading = true; | |
// load something new and set adapter notifyDatasetChanged | |
// 记得在 load something 完了以后把 onLoading 赋值为 false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment