I am building an app in which I want to enable swipe. I want to swipe xml layouts but in a single activity. Earlier I tried to put images, it worked. I created an ImageAdapter c
For your first question, the Infinite Scrolling, I figured out one solution to it.
Here's how I am doing it:
No looping is required in this case. No matter what your getCount() is.
After setting the adapter, I am setting a setOnPageChangeListener to the view pager like this:
myPager.setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
//Define the focused page before your onCreate()..private int focusedPage = 0;
focusedPage = position;
}
//We don't have to do anything here.
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
// TODO Auto-generated method stub
}
//Here's where the magic is. After you reach the end of the page, you can scroll again and it will move your view to page 1 again.
@Override
public void onPageScrollStateChanged(int arg0) {
myPager.setCurrentItem(0,false);
}
});
See if this solution works.. It's working perfect for me. .:D