Code example for ViewPager

Methods: setAdapter, setId

0
     
	@Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         
        ViewPager pager = new ViewPager(this);
        pager.setId(1);
        setContentView(pager);
         
        pager.setAdapter(new TestAdapter(getSupportFragmentManager()));
        invalidateOptionsMenu(); 
    } 
	 
	@Override 
    public boolean onCreateOptionsMenu(Menu menu) {
	    mMenu = menu;
        return super.onCreateOptionsMenu(menu);
    } 
	 
	public Menu getMenu() {
	    return mMenu;