Hello, I am a beginner in android studio. In a project, after getting images and text from database, they will show in a recyclerview.
In the project:
minSdkVersion 15
targetSdkVersion 23
First 5 items will show and then after checking that the recyclerview scroll has reached the bottom, other items will download.
private boolean isLastItemDisplaying(RecyclerView recyclerView) {
if (recyclerView.getAdapter().getItemCount() != 0) {
int lastVisibleItemPosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastCompletelyVisibleItemPosition();
if (lastVisibleItemPosition != RecyclerView.NO_POSITION && lastVisibleItemPosition == recyclerView.getAdapter().getItemCount() - 1)
return true;
}
return false;
}
@Override
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
if (isLastItemDisplaying(recyclerView)) {
getData();
}
}
But
public class Last_pics extends Fragment implements RecyclerView.OnScrollChangeListener{
needs min sdk 23.
How can I implement it without changing minimum sdk version?
Is there other ways?
Thanks
What I have tried:
implementing
RecyclerView.OnScrollChangeListener
for downloading sections of data from database? Is there other ways to doing it?