I have a project with three fragments and I can swipe the fragments horizontally using the View Pager. I want to load the first fragment again after swiping the third fragment.According to my code I can only swipe until the third fragment.To view the first fragment I have to swipe backwards.
I think we have to include a logic here. As I'm new to programming it would be grate if someone can help me.
I have provided the code below.Thank you in advance for any help.
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
public class PagerAdapter extends FragmentPagerAdapter {
public PagerAdapter(FragmentManager fm) {
super(fm);
// TODO Auto-generated constructor stub
}
@Override
public Fragment getItem(int arg0) {
// TODO Auto-generated method stub
switch(arg0){
case 0:
return new FragmentOne();
case 1:
return new FragmentTwo();
case 2:
return new FragmentThree();
default:
break;
}
return null;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 3;
}
}