Code example for ViewPager

Methods: setAdapter, setId, setPageTransformer

0
public class PagerActivity extends SherlockFragmentActivity { 
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ViewPager pager = new ViewPager(this);
        pager.setPageTransformer(false, new AccordianPageTransformer());
        pager.setId(99);
        setContentView(pager);
        MyAdapter adapter = new MyAdapter(getSupportFragmentManager());
        adapter.addPage("Fragment #1", Color.RED);
        adapter.addPage("Fragment #2", Color.BLUE);
        adapter.addPage("Fragment #3", Color.GREEN);
        pager.setAdapter(adapter);
    } 
     
    /** 
     * Performs Y-Axis card-flip animation. 
     */ 
    public static class FlipPageTransformer implements PageTransformer {