Last active
July 14, 2018 12:20
-
-
Save sh-zam/40b3289cae60db884f44dfbdc0656873 to your computer and use it in GitHub Desktop.
Infinite gridView scrolling android with custom adapter
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
public class InfiniteScrollCustomAdapter extends ArrayAdapter<DataItems> { | |
// .... your code ..... | |
@NonNull | |
@Override | |
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { | |
int MAX_ITEM_PER_PAGE = 100; | |
// so data is retrieved before the page ends and user doesn't have to wait | |
if (position > (MAX_ITEM_PER_PAGE - 10)) { | |
// dataFetcher.next() should add to original list | |
dataFetcher.next(); | |
} | |
if (convertView == null) { | |
convertView = getActivity().getLayoutInflater() | |
.inflate(R.layout.custom_layout, parent, false); | |
} | |
return convertView; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment