I have problem with android viewpager slideshow. I want to show the viewpager layout after a minimum time period. Here is my code sample. My main class: <
Use Handler to make it auto slide. Here is some code
private Handler handler = new Handler();
private Runnable runnable = new Runnable() {
public void run() {
if( position >= 4){
position = 0;
}else{
position = position+1;
}
toBarPager.setCurrentItem(position, true);
handler.postDelayed(runnable, 10000);
}
};
And don't forget to remove callback onPause()
@Override
public void onPause() {
super.onPause();
if (handler!= null) {
handler.removeCallbacks(runnable);
}
}
Also, don't forget to rerun onResume()
@Override
public void onResume() {
super.onResume(); // Always call the superclass method first
handler.postDelayed(runnable, 10000);
}
use Handler and send[Empty]MessageDelayed/postDelayed and call setCurrentItem on your ViewPager