Skip to content

Instantly share code, notes, and snippets.

@aria-dev
Created August 29, 2019 07:51
Show Gist options
  • Save aria-dev/a2ea1756feb5fe009590c6a326919427 to your computer and use it in GitHub Desktop.
Save aria-dev/a2ea1756feb5fe009590c6a326919427 to your computer and use it in GitHub Desktop.
// Auto start of viewpager
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
// Auto start of viewpager
final Handler handler = new Handler();
final Runnable Update = new Runnable() {
public void run() {
if (currentPage == NUM_PAGES) {
currentPage = 0;
}
mPager.setCurrentItem(currentPage++, true);
}
};
Timer swipeTimer = new Timer();
swipeTimer.schedule(new TimerTask() {
@Override
public void run() {
handler.post(Update);
}
}, 3000, 3000);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment