Skip to content

Instantly share code, notes, and snippets.

@BramYeh
Created August 15, 2017 05:07
Show Gist options
  • Save BramYeh/e0d3fa355dad297ab0a6f553c6989abe to your computer and use it in GitHub Desktop.
Save BramYeh/e0d3fa355dad297ab0a6f553c6989abe to your computer and use it in GitHub Desktop.
CycleViewPager Example
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