ActionBar setSelectedNavigationItem - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ActionBar setSelectedNavigationItem method.

This code example shows how to use the following methods:setSelectedNavigationItem
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        } 
 
        @Override 
        public void onPageSelected(int position) {
            mActionBar.setSelectedNavigationItem(position);
        } 
 
        @Override 
        public void onPageScrollStateChanged(int state) {
        } 
 
        @Override 
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            Object tag = tab.getTag();
            for (int i=0; i<mTabs.size(); i++) {
                if (mTabs.get(i) == tag) {
                    mViewPager.setCurrentItem(i);
                } 
            } 
6
CodeRank
This code example shows how to use the following methods:setSelectedNavigationItem
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        } 
 
        @Override 
        public void onPageSelected(int position) {
            mActionBar.setSelectedNavigationItem(position);
        } 
 
        @Override 
        public void onPageScrollStateChanged(int state) {
        } 
 
        @Override 
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            Object tag = tab.getTag();
            for (int i=0; i<mTabs.size(); i++) {
                if (mTabs.get(i) == tag) {
                    mViewPager.setCurrentItem(i);
                } 
            } 
6
CodeRank
This code example shows how to use the following methods:getNavigationMode, getSelectedNavigationIndex, setSelectedNavigationItem
        if (tab == mCurrentTab) {
            return; 
        } 
        mCurrentTab = tab;
 
        final int actionBarSelectedNavIndex = mActionBar.getSelectedNavigationIndex();
        switch(mActionBar.getNavigationMode()) {
            case ActionBar.NAVIGATION_MODE_TABS:
                if (mCurrentTab != actionBarSelectedNavIndex) {
                    mActionBar.setSelectedNavigationItem(mCurrentTab);
                } 
                break; 
            case ActionBar.NAVIGATION_MODE_LIST:
                if (mCurrentTab != getTabPositionFromNavigationItemPosition(
                        actionBarSelectedNavIndex)) {
                    mActionBar.setSelectedNavigationItem(
                            getNavigationItemPositionFromTabPosition(mCurrentTab));
                } 
                break; 
        } 
 
7
CodeRank
This code example shows how to use the following methods:setSelectedNavigationItem
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        } 
 
        @Override 
        public void onPageSelected(int position) {
            mActionBar.setSelectedNavigationItem(position);
        } 
 
        @Override 
        public void onPageScrollStateChanged(int state) {
        } 
 
        @Override 
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            Object tag = tab.getTag();
            for (int i=0; i<mTabs.size(); i++) {
                if (mTabs.get(i) == tag) {
                    mViewPager.setCurrentItem(i);
                } 
            } 
6
CodeRank
This code example shows how to use the following methods:setDisplayHomeAsUpEnabled, setDisplayShowTitleEnabled, setListNavigationCallbacks, setNavigationMode, setSelectedNavigationItem
        } 
    } 
 
    private void setupActionBar(Bundle savedInstanceState) {
        bar = getActionBar();
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setDisplayShowTitleEnabled(false);
        bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
 
        adapter = new FilterAdapter(this);
        adapter.setTitle(Subreddits.getTitle(this, subreddit));
        bar.setListNavigationCallbacks(adapter, this);
        if (savedInstanceState != null) {
            bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_NAVIGATION_INDEX));
        } 
    } 
 
    public Loader<AccountResult> onCreateLoader(int id, Bundle args) {
        return new AccountLoader(this, true, false);
    } 
7
CodeRank
This code example shows how to use the following methods:addTab, newTab, setNavigationMode, setSelectedNavigationItem
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
		actionBar = getActionBar();
		actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
		 
		Tab tab = actionBar.newTab().setText("Venda").setTabListener(new MyTabListener<SaleFragment>(this, "venda", SaleFragment.class));
		actionBar.addTab(tab);
		tab = actionBar.newTab().setText("Locação").setTabListener(new MyTabListener<RentFragment>(this, "locacao", RentFragment.class));
		actionBar.addTab(tab);
		tab = actionBar.newTab().setText("Clientes").setTabListener(new MyTabListener<ClientFragment>(this, "cliente", ClientFragment.class));
		actionBar.addTab(tab);
		 
		if(savedInstanceState != null) {
			actionBar.setSelectedNavigationItem(savedInstanceState.getInt("selected"));
		} 
	} 
 
	@Override 
	public boolean onCreateOptionsMenu(Menu menu) {
6
CodeRank
This code example shows how to use the following methods:setSelectedNavigationItem
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        } 
 
        @Override 
        public void onPageSelected(int position) {
            mActionBar.setSelectedNavigationItem(position);
        } 
 
        @Override 
        public void onPageScrollStateChanged(int state) {
        } 
 
        @Override 
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            Object tag = tab.getTag();
            for (int i=0; i<mTabs.size(); i++) {
                if (mTabs.get(i) == tag) {
                    mViewPager.setCurrentItem(i);
                } 
            } 
6
CodeRank
This code example shows how to use the following methods:setSelectedNavigationItem
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        } 
 
        @Override 
        public void onPageSelected(int position) {
            mActionBar.setSelectedNavigationItem(position);
        } 
 
        @Override 
        public void onPageScrollStateChanged(int state) {
        } 
 
        @Override 
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            Object tag = tab.getTag();
            for (int i=0; i<mTabs.size(); i++) {
                if (mTabs.get(i) == tag) {
                    mViewPager.setCurrentItem(i);
                } 
            } 
6
CodeRank
This code example shows how to use the following methods:addTab, newTab, setDisplayShowTitleEnabled, setNavigationMode, setSelectedNavigationItem
 
    private ActionBar actionBar;
 
    private void init_action_bar() { 
        actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle("I am new here...");
        actionBar.addTab(actionBar.newTab()
                .setText("Lectures")
                .setTabListener(new TabListener<LectureFragment>(
                        this, "lectures", LectureFragment.class)));
        actionBar.addTab(actionBar.newTab()
                .setText("Map")
                .setTabListener(new TabListener<MapFragment>(
                        this, "map", MapFragment.class)));
        actionBar.addTab(actionBar.newTab()
                .setText("Todo")
                .setTabListener(new TabListener<TodoFragment>(
                        this, "todo", TodoFragment.class)));

6
CodeRank
This code example shows how to use the following methods:addTab, newTab, setDisplayShowHomeEnabled, setDisplayShowTitleEnabled, setNavigationMode
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        final ActionBar bar = getActionBar();
        bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        bar.setDisplayShowHomeEnabled(false);
        bar.setDisplayShowTitleEnabled(false);
 
        bar.addTab(bar
                .newTab()
                .setText("Podcasts")
                .setTabListener(
                        new TabListener<PodcastsFragment>(this, "podcasts", PodcastsFragment.class)));
 
        bar.addTab(bar
                .newTab()
                .setText("Favorite")
                .setTabListener(
                        new TabListener<FavorFragment>(this, "favorite",

6
CodeRank
setSelectedNavigationItem Method Overview
Set the selected navigation item in list or tabbed navigation modes.
See Code Examples for other Android ActionBar Methods: