Code example for ViewPager

Methods: getContext, setAdapter, setOnPageChangeListener

0
        super(context);
    } 
     
    public void initializeAdapter(FragmentManager manager, ActionBar bar) {
        this.bar = bar;
        adapter = new DefaultFragmentPagerAdapter(getContext(),manager,bar);
        adapter.setActionBar(bar);
        setAdapter(adapter);
        pageListener = new DefaultViewPagerListener(bar);
        super.setOnPageChangeListener(pageListener);
    } 
 
    @Override 
    public void setOnPageChangeListener(OnPageChangeListener listener) {
        pageListener.setOnPageChangeListener(listener);
    } 
     
 
    /** 
     * This method adds a tab to the FragmentPager's ActionBar associated with a Fragment.  
     * If a TabListener is not supplied, DefaultViewPagerTabListener will be used.