Become a member
Sign in
Looping/infinite ViewPager with page indicator in Android
711
13
Ali Muzaffar
Benoit Daffos
Benoit Daffos
Sep 1, 2018 · 1 min read

This article was helpful !

Instead of overriding destroyItem to remove and recreate the fragment, I override getItemId. So the tag of the fragment doesn’t have to be changed.

@Override
public long getItemId(int position) {
return super.getItemId(position % titles.size());
}

So far, it works like a charm.

    Benoit Daffos

    Written by

    Benoit Daffos

    Write the first response

    Discover Medium

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

    Make Medium yours

    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

    Become a member

    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade
    AboutHelpLegal