android.app.ActionBar#addTab ( )源码实例Demo

下面列出了android.app.ActionBar#addTab ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: mOrgAnd   文件: MainActivity.java
private void initViewPager(final ActionBar actionBar) {
    mSectionsPagerAdapter = new MainPagerAdapter(getSupportFragmentManager());
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        actionBar.addTab(
                actionBar.newTab()
                        .setText(mSectionsPagerAdapter.getPageTitle(i))
                        .setTabListener(this));
    }
}
 
源代码2 项目: holoaccent   文件: TabbedActivity.java
protected void configureTabs(final ActionBar actionBar, ViewPager viewPager) {
	
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

	viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
				@Override public void onPageSelected(int position) {
					actionBar.setSelectedNavigationItem(position);
				}
			});

	// For each of the sections in the app, add a tab to the action bar.
	for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
		Tab newTab = actionBar.newTab()
				.setText(mSectionsPagerAdapter.getPageTitle(i))
				.setTabListener(this);
		actionBar.addTab(newTab);
	}
}
 
源代码3 项目: pixate-freestyle-android   文件: MainActivity.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    Tab tab = actionBar.newTab().setText(R.string.tab1_title)
            .setTabListener(new TabListener(this, Fragment1.class.getName()));
    actionBar.addTab(tab);
    tab = actionBar.newTab().setText(R.string.tab2_title)
            .setTabListener(new TabListener(this, Fragment2.class.getName()));
    actionBar.addTab(tab);
    tab = actionBar.newTab().setText(R.string.tab3_title)
            .setTabListener(new TabListener(this, Fragment3.class.getName()));
    actionBar.addTab(tab);

    // Initiate Pixate
    PixateFreestyle.init(this);
}
 
源代码4 项目: android   文件: ActivityMain.java
private void cargaPestanas() {
	
	Resources res = getResources();
    
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    
    // Crea las tabs
    ActionBar.Tab tab1 = actionBar.newTab().setText(res.getString(R.string.listado_gasolineras_title));
    ActionBar.Tab tab2 = actionBar.newTab().setText(res.getString(R.string.misubicaciones_title));
    
    // Crea cada Fragment para luego asociarla con la pestaña que corresponda
    Fragment fragmentoTab1 = new ListaGasolineras();
    Fragment fragmentoTab2 = new MisUbicaciones();
    
    // Asocia cada Fragment con su tab
    tab1.setTabListener(new TabsListener(fragmentoTab1));
    tab2.setTabListener(new TabsListener(fragmentoTab2));
    
    // Añade las tabs a la ActionBar
    actionBar.addTab(tab1);
    actionBar.addTab(tab2);
}
 
源代码5 项目: android   文件: ActivityMain.java
private void cargaPestanas() {
	
	Resources res = getResources();
    
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    
    // Crea las tabs
    ActionBar.Tab tab1 = actionBar.newTab().setText(res.getString(R.string.listado_gasolineras_title));
    ActionBar.Tab tab2 = actionBar.newTab().setText(res.getString(R.string.misubicaciones_title));
    
    // Crea cada Fragment para luego asociarla con la pestaña que corresponda
    Fragment fragmentoTab1 = new ListaGasolineras();
    Fragment fragmentoTab2 = new MisUbicaciones();
    
    // Asocia cada Fragment con su tab
    tab1.setTabListener(new TabsListener(fragmentoTab1));
    tab2.setTabListener(new TabsListener(fragmentoTab2));
    
    // Añade las tabs a la ActionBar
    actionBar.addTab(tab1);
    actionBar.addTab(tab2);
}
 
源代码6 项目: SensorTag-CC2650   文件: ViewPagerActivity.java
public void addSection(Fragment fragment, String title) {
  final ActionBar actionBar = getActionBar();
  mFragmentList.add(fragment);
  mTitles.add(title);
  actionBar.addTab(actionBar.newTab().setText(title).setTabListener(tabListener));
  notifyDataSetChanged();
  // Log.d(TAG, "Tab: " + title);
}
 
源代码7 项目: androidtestdebug   文件: MainActivity.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if(savedInstanceState != null && savedInstanceState.getInt("theme", -1) != -1) {
        mThemeId = savedInstanceState.getInt("theme");
        this.setTheme(mThemeId);
    }
            
    setContentView(R.layout.main);

    Directory.initializeDirectory(new OnDirectoryChanged());
    
    ActionBar bar = getActionBar();

    int i;
    for (i = 0; i < Directory.getCategoryCount(); i++) {
        bar.addTab(bar.newTab().setText(Directory.getCategory(i).getName())
                .setTabListener(this));
    }

    mActionBarView = getLayoutInflater().inflate(
            R.layout.action_bar_custom, null);

    bar.setCustomView(mActionBarView);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO);
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayShowHomeEnabled(true);

    // If category is not saved to the savedInstanceState,
    // 0 is returned by default.
    if(savedInstanceState != null) {
        int category = savedInstanceState.getInt("category");
        bar.selectTab(bar.getTabAt(category));
    }
}
 
源代码8 项目: AnyTime   文件: MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	activity = this;
	// Set up the action bar.
	final ActionBar actionBar = getActionBar();
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

	// Create the adapter that will return a fragment for each of the three
	// primary sections of the app.
	mSectionsPagerAdapter = new SectionsPagerAdapter(
			getSupportFragmentManager());

	// Set up the ViewPager with the sections adapter.
	mViewPager = (ViewPager) findViewById(R.id.pager);
	mViewPager.setAdapter(mSectionsPagerAdapter);

	// When swiping between different sections, select the corresponding
	// tab. We can also use ActionBar.Tab#select() to do this if we have
	// a reference to the Tab.
	mViewPager
			.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
				@Override
				public void onPageSelected(int position) {
					actionBar.setSelectedNavigationItem(position);
				}
			});

	// For each of the sections in the app, add a tab to the action bar.
	for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
		// Create a tab with text corresponding to the page title defined by
		// the adapter. Also specify this Activity object, which implements
		// the TabListener interface, as the callback (listener) for when
		// this tab is selected.
		actionBar.addTab(actionBar.newTab()
				.setText(mSectionsPagerAdapter.getPageTitle(i))
				.setTabListener(this));
	}
}
 
源代码9 项目: androidtestdebug   文件: MainActivity.java
@Override
  public void onCreate(Bundle savedInstanceState) {		
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
	.detectActivityLeaks()
	.penaltyLog().build());

      super.onCreate(savedInstanceState);

      if(savedInstanceState != null && savedInstanceState.getInt("theme", -1) != -1) {
          mThemeId = savedInstanceState.getInt("theme");
          this.setTheme(mThemeId);
      }
              
      setContentView(R.layout.main);

      Directory.initializeDirectory(new OnDirectoryChanged());
      
      ActionBar bar = getActionBar();

      int i;
      for (i = 0; i < Directory.getCategoryCount(); i++) {
          bar.addTab(bar.newTab().setText(Directory.getCategory(i).getName())
                  .setTabListener(this));
      }

      mActionBarView = getLayoutInflater().inflate(
              R.layout.action_bar_custom, null);

      bar.setCustomView(mActionBarView);
      bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO);
      bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
      bar.setDisplayShowHomeEnabled(true);

      // If category is not saved to the savedInstanceState,
      // 0 is returned by default.
      if(savedInstanceState != null) {
          int category = savedInstanceState.getInt("category");
          bar.selectTab(bar.getTabAt(category));
      }
  }
 
源代码10 项目: codeexamples-android   文件: FragmentTabs.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

    bar.addTab(bar.newTab()
            .setText("Simple")
            .setTabListener(new TabListener<FragmentStack.CountingFragment>(
                    this, "simple", FragmentStack.CountingFragment.class)));
    bar.addTab(bar.newTab()
            .setText("Contacts")
            .setTabListener(new TabListener<LoaderCursor.CursorLoaderListFragment>(
                    this, "contacts", LoaderCursor.CursorLoaderListFragment.class)));
    bar.addTab(bar.newTab()
            .setText("Apps")
            .setTabListener(new TabListener<LoaderCustom.AppListFragment>(
                    this, "apps", LoaderCustom.AppListFragment.class)));
    bar.addTab(bar.newTab()
            .setText("Throttle")
            .setTabListener(new TabListener<LoaderThrottle.ThrottledLoaderListFragment>(
                    this, "throttle", LoaderThrottle.ThrottledLoaderListFragment.class)));

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_green_dao_sample);
    // appcompatに対応すると2.1から利用出来る
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mDaoSession = ((GreenDaoSampleApplication) getApplication())
            .getDaoSession();

    mSectionsPagerAdapter = new SectionsPagerAdapter(
            getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager
            .setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
                @Override
                public void onPageSelected(int position) {
                    actionBar.setSelectedNavigationItem(position);
                }
            });
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        actionBar.addTab(actionBar.newTab()
                .setText(mSectionsPagerAdapter.getPageTitle(i))
                .setTabListener(this));
    }

}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_host);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);


    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar.addTab(
                actionBar.newTab()
                        .setText(mSectionsPagerAdapter.getPageTitle(i))
                        .setTabListener(this));
    }
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_parallax_everywhere_sample);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar.addTab(
                actionBar.newTab()
                        .setText(mSectionsPagerAdapter.getPageTitle(i))
                        .setTabListener(this));
    }
}
 
源代码14 项目: remoteyourcam-usb   文件: MainActivity.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (AppConfig.LOG) {
        Log.i(TAG, "onCreate");
    }

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    if (!getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)) {
        getWindow()
                .setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        isLarge = true;
    }

    setContentView(R.layout.session);

    settings = new AppSettings(this);

    ActionBar bar = getActionBar();

    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayHomeAsUpEnabled(false);
    bar.addTab(bar.newTab().setText("Session").setTabListener(new MyTabListener(new TabletSessionFragment())));
    bar.addTab(bar.newTab().setText("Gallery").setTabListener(new MyTabListener(new GalleryFragment())));

    int appVersionCode = -1;
    try {
        appVersionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (NameNotFoundException e) {
        // nop
    }

    if (settings.showChangelog(appVersionCode)) {
        showChangelog();
    }

    ptp = PtpService.Singleton.getInstance(this);
}
 
源代码15 项目: BLEChat   文件: MainActivity.java
/*****************************************************
 *	 Overrided methods
 ******************************************************/

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	//----- System, Context
	mContext = this;	//.getApplicationContext();
	mActivityHandler = new ActivityHandler();
	AppSettings.initializeAppSettings(mContext);
	
	setContentView(R.layout.activity_main);

	// Set up the action bar.
	final ActionBar actionBar = getActionBar();
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

	// Create the adapter that will return a fragment for each of the primary sections of the app.
	mFragmentManager = getSupportFragmentManager();
	mSectionsPagerAdapter = new FragmentAdapter(mFragmentManager, mContext, this, mActivityHandler);

	// Set up the ViewPager with the sections adapter.
	mViewPager = (ViewPager) findViewById(R.id.pager);
	mViewPager.setAdapter(mSectionsPagerAdapter);

	// When swiping between different sections, select the corresponding tab.
	mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
		@Override
		public void onPageSelected(int position) {
			actionBar.setSelectedNavigationItem(position);
		}
	});

	// For each of the sections in the app, add a tab to the action bar.
	for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
		// Create a tab with text corresponding to the page title defined by the adapter.
		actionBar.addTab(actionBar.newTab()
				.setText(mSectionsPagerAdapter.getPageTitle(i))
				.setTabListener(this));
	}
	
	// Setup views
	mImageBT = (ImageView) findViewById(R.id.status_title);
	mImageBT.setImageDrawable(getResources().getDrawable(android.R.drawable.presence_invisible));
	mTextStatus = (TextView) findViewById(R.id.status_text);
	mTextStatus.setText(getResources().getString(R.string.bt_state_init));
	
	// Do data initialization after service started and binded
	doStartService();
}
 
源代码16 项目: BTChat   文件: MainActivity.java
/*****************************************************
 *	 Overrided methods
 ******************************************************/

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	//----- System, Context
	mContext = this;	//.getApplicationContext();
	mActivityHandler = new ActivityHandler();
	AppSettings.initializeAppSettings(mContext);
	
	setContentView(R.layout.activity_main);

	// Set up the action bar.
	final ActionBar actionBar = getActionBar();
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

	// Create the adapter that will return a fragment for each of the primary sections of the app.
	mFragmentManager = getSupportFragmentManager();
	mSectionsPagerAdapter = new FragmentAdapter(mFragmentManager, mContext, this, mActivityHandler);

	// Set up the ViewPager with the sections adapter.
	mViewPager = (ViewPager) findViewById(R.id.pager);
	mViewPager.setAdapter(mSectionsPagerAdapter);

	// When swiping between different sections, select the corresponding tab.
	mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
		@Override
		public void onPageSelected(int position) {
			actionBar.setSelectedNavigationItem(position);
		}
	});

	// For each of the sections in the app, add a tab to the action bar.
	for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
		// Create a tab with text corresponding to the page title defined by the adapter.
		actionBar.addTab(actionBar.newTab()
				.setText(mSectionsPagerAdapter.getPageTitle(i))
				.setTabListener(this));
	}
	
	// Setup views
	mImageBT = (ImageView) findViewById(R.id.status_title);
	mImageBT.setImageDrawable(getResources().getDrawable(android.R.drawable.presence_invisible));
	mTextStatus = (TextView) findViewById(R.id.status_text);
	mTextStatus.setText(getResources().getString(R.string.bt_state_init));
	
	// Do data initialization after service started and binded
	doStartService();
}
 
源代码17 项目: bankomatinfos   文件: ResultActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_result);
	_showQuickLog = (_controller.getCardInfoNullSafe(this).getQuickLog()
			.size() > 0);
	_showEmvLog = _controller.getCardInfoNullSafe(this).isEmvCard();
	if (_showEmvLog && _showQuickLog) {
		_numLogTabs = 2;
	} else {
		_numLogTabs = 1;
	}
	_fragmentResultInfos = new ResultInfosListFragment();
	if (_showEmvLog) {
		_fragmentResultEmxTxList = new ResultEmvTxListFragment();
	}
	if (_showQuickLog) {
		_fragmentResultQuickTxList = new ResultQuickTxListFragment();
	}
	_fragmentResultLog = new ResultLogFragment();

	// Set up the action bar.
	final ActionBar actionBar = getActionBar();
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

	// Create the adapter that will return a fragment for each of the
	// primary sections of the app.
	_sectionsPagerAdapter = new SectionsPagerAdapter(
			getSupportFragmentManager());

	// Set up the ViewPager with the sections adapter.
	_viewPager = (ViewPager) findViewById(R.id.pager);
	_viewPager.setAdapter(_sectionsPagerAdapter);

	// When swiping between different sections, select the corresponding
	// tab. We can also use ActionBar.Tab#select() to do this if we have
	// a reference to the Tab.
	_viewPager
			.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
				@Override
				public void onPageSelected(int position) {
					actionBar.setSelectedNavigationItem(position);
				}
			});

	// For each of the sections in the app, add a tab to the action bar.
	for (int i = 0; i < _sectionsPagerAdapter.getCount(); i++) {
		// Create a tab with text corresponding to the page title defined by
		// the adapter. Also specify this Activity object, which implements
		// the TabListener interface, as the callback (listener) for when
		// this tab is selected.
		actionBar.addTab(actionBar.newTab()
				.setText(_sectionsPagerAdapter.getPageTitle(i))
				.setTabListener(this));
	}
}
 
源代码18 项目: androidtestdebug   文件: MainActivity.java
@Override
public void addingNew(DirectoryCategory category) {
       ActionBar bar = getActionBar();
          bar.addTab(bar.newTab().setText(category.getName())
                  .setTabListener(getActivity()));
}
 
源代码19 项目: androidtestdebug   文件: MainActivity.java
@Override
public void addingNew(DirectoryCategory category) {
       ActionBar bar = getActionBar();
          bar.addTab(bar.newTab().setText(category.getName())
                  .setTabListener(getActivity()));
}
 
源代码20 项目: codeexamples-android   文件: MainActivity.java
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab()
                        .setText(mAppSectionsPagerAdapter.getPageTitle(i))
                        .setTabListener(this));
    }
}