Created
August 15, 2017 05:07
-
-
Save BramYeh/e0d3fa355dad297ab0a6f553c6989abe to your computer and use it in GitHub Desktop.
CycleViewPager Example
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 CycleViewPager extends ViewPager { | |
public CycleViewPager(Context context) { | |
super(context); | |
} | |
public CycleViewPager(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
@Override | |
public void setAdapter(@NonNull PagerAdapter adapter) { | |
super.setAdapter(adapter); | |
// after setting adapter, maybe scroll to 2nd itemview | |
if (adapter.getCount() > 1) { | |
setCurrentItem(1, false); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment