title: Make a looping ViewPager
body: <p>I have this class of a <code>FragmentPagerAdapter</code>.</p>
  
  <p>How could I turn this into a looping ViewPager? So from A - B- C - A(back). I have tried some solutions on this forum, but it doesn't bring me any result.</p>
  
  <pre><code>public class RootCategoriesPagerAdapter extends FragmentPagerAdapter {
  
      private static final Logger LOG = LoggerFactory.getLogger(RootCategoriesPagerAdapter.class.getSimpleName());
  
      private final AppDomainResult appDomain;
  
      public RootCategoriesPagerAdapter(final AppDomainResult appDomain, final FragmentManager fragmentManager) {
          super(fragmentManager);
          this.appDomain = checkNotNull(appDomain, "appDomain");
      }
  
      @Override
      public int getCount() {
          return appDomain.getRootCategories().size();
      }
  
      @Override
      public Fragment getItem(final int position) {
  
          LOG.debug("Creating new Fragment for position {}", position);
  
          final RootCategoryResult rootCategory = appDomain.getRootCategories().get(position);
          LOG.debug("{}", rootCategory);
  
          return createRootCategoryFragment(rootCategory);
      }
  
      private CategoryFragment createRootCategoryFragment(final RootCategoryResult rootCategory) {
  
          return CategoryFragment.newInstance(rootCategory.getUrlKey(), createViewConfig(rootCategory));
      }
  
      private static CategoriesAdapterViewConfig createViewConfig(final RootCategoryResult rootCategory) {
          //J-
          return new CategoriesAdapterViewConfig()
                  .sourceActivity(SHOP)
                  .showTeasers(true)
                  .resourceTop(R.drawable.shop_top)
                  .resourceMiddle(R.drawable.shop_middle)
                  .resourceBottom(R.drawable.shop_bottom)
                  .showSearchBar(Optional.fromNullable(rootCategory.getIsHome()).or(false));
          //J+
      }
  
      @Override
      public CharSequence getPageTitle(final int position) {
          return appDomain.getRootCategories().get(position).getLabel();
      }
  </code></pre>