Code example for ActionBarActivity

Methods: getSupportActionBar, supportInvalidateOptionsMenu

0
    } 
 
    @Override 
    public void setTitle(CharSequence title) {
        mTitle = title;
        getSupportActionBar().setTitle(mTitle);
    } 
 
    @Override 
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        // Sync the toggle state after onRestoreInstanceState has occurred. 
        mDrawerToggle.syncState();
    } 
 
    @Override 
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        // Pass any configuration change to the drawer toggls 
        mDrawerToggle.onConfigurationChanged(newConfig);
    } 
 
    @Override 
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        if (mDrawerLayout.isDrawerOpen(mDrawerList)) {
            outState.putString(TITLE_KEY, mDrawerTitle.toString());
        } else { 
            outState.putString(TITLE_KEY, mTitle.toString());
        } 
    } 
 
    public void selectItem(int position) {
        supportInvalidateOptionsMenu(); 
        mViewPager.setCurrentItem(position);
        mDrawerList.setItemChecked(position, true);
        setTitle(mMenuTitles[position]);
        mDrawerLayout.closeDrawer(mDrawerList);
    }