5

I want to simulate a fakeDrag on a viewpager and I searched for sometime but I couldn't find any good example for it. here is what i'v done:

public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);    
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
    @Override
    public void run() {
        viewPager.beginFakeDrag();
        // I dont know what this number mean
        vewPager.fakeDragBy(1000);
        Handler handler1 = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                viewPager.endFakeDrag();
        }
        }, 1000);
    }
}, 1000);
}

I don't really know what fakeDragBy() does and how to make it longer. could you give me a working example for this?

  • Take a look at [this answer](http://stackoverflow.com/a/30976853/2418367), there is a working example for fakeDragging. – Dominikus K. Jan 09 '16 at 20:33

1 Answers1

0

Have you used this?

viewPager.setCurrentItem(i);

where i is the index of view pager.

Ahmad Behzadi
  • 1,006
  • 15
  • 30