Tag: viewpager

  • Indicators library

    Recently, I created a custom view, and after having used it for several of my projects, I decided to publish it as a library.

    How to use it: https://github.com/Pulimet/Indicators-Library

    <net.alexandroid.utils.indicators.IndicatorsView
        android:id="@+id/indicatorsView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    
        app:indicatorSize="20dp"
        app:paddingBetweenIndicators="16dp"
    
        app:selectedDrawable="@drawable/custom_selected"
        app:unSelectedDrawable="@drawable/custom_unselected"/>
  • ViewPager Fragments – onPageSelected/onPageUnSelected

    Sometimes we need to know when fragment is selected and to handle it.

    1. Add interface:

        public interface FragmentSelection{
            void onPageUnSelected();
            void onPageSelected();
        }
    

    2. Implement this interface in your fragments:
    (more…)

  • Infinite ViewPager

    MainActivity – onCreate()

    ...
    SectionsPagerAdapter mSectionsPagerAdapter = 
            new SectionsPagerAdapter(getSupportFragmentManager(), numOfPages);
    ViewPager viewPager = (ViewPager) findViewById(R.id.container_view_pager);
    viewPager.setAdapter(mSectionsPagerAdapter);
    viewPager.setCurrentItem(1000 * numOfPages);
    ...
    

    (more…)