Android ActionBar - top ranked examples from Open Source projects

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

This code example shows how to use the following methods: setBackgroundDrawable, setCustomView, setDisplayShowCustomEnabled, setDisplayShowTitleEnabled
     * @param title The title for the action bar 
     * @param subtitle The subtitle for the action bar. 
     */ 
    public void themeActionBar(final ActionBar actionBar, final String title) {
        // Set the custom layout 
        actionBar.setCustomView(mActionBarLayout);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
 
        // Theme the action bar background 
        actionBar.setBackgroundDrawable(getDrawable("action_bar"));
 
        // Theme the title 
        setTitle(title);
    } 
 
    /** 
     * Themes the action bar subtitle 
     *  
     * @param subtitle The subtitle to use 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setDisplayHomeAsUpEnabled, setDisplayOptions, setIcon
 
		setContentView(getBaseLayout());
 
		bar = getActionBar();
		if (bar != null) {
			bar.setIcon(getIcon());
			bar.setDisplayOptions(0, ActionBar.DISPLAY_HOME_AS_UP);
			bar.setDisplayHomeAsUpEnabled(true);
		} 
		replace(); 
	} 
 
	public void replace() { 
		getFragmentManager().beginTransaction()
				.replace(getReplaceId(), replaceFragment()).commit();
	} 
 
	public abstract int getIcon(); 
 
	public abstract boolean getCondition(); 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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);
    } 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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; 
        } 
 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setDisplayHomeAsUpEnabled, setDisplayShowTitleEnabled
		// Must do this before super.onCreate 
		ActivityHelper.readAndSetSettings(this);
		super.onCreate(savedInstanceState);
 
		final ActionBar actionBar = getActionBar();
		actionBar.setDisplayShowTitleEnabled(true);
		actionBar.setDisplayHomeAsUpEnabled(true);
 
		handleIntent(getIntent()); 
	} 
	 
	/** 
	 * To allow child classes to override content 
	 */ 
	protected Fragment getFragment() {
		return FragmentSearch.getInstance(mQuery);
	} 
 
	@AfterViews 
	void loadContent() { 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setHomeButtonEnabled
	private static class SetHomeButtonEnabledAccessor { 
 
		private static void setHomeButtonEnabled(final Activity activity, final boolean enabled) {
			if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) return;
			final ActionBar action_bar = activity.getActionBar();
			action_bar.setHomeButtonEnabled(enabled);
		} 
	} 
} 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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);
                } 
            } 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
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);
                } 
            } 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: addTab, newTab, setNavigationMode
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         
       // System.out.println(savedInstanceState.getInt("tabState",0)); 
        ActionBar b = getActionBar();
        b.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        Tab tab = b.newTab().setText("Library").setTabListener(new TabListener<LibraryActivity>(this, "library", LibraryActivity.class));
        b.addTab(tab, 0, true);
         
        tab = b.newTab().setText("Queue").setTabListener(new TabListener<QueueActivity>(this, "queue", QueueActivity.class));
        b.addTab(tab, 1, false);
         
        tab = b.newTab().setText("Now Playing").setTabListener(new TabListener<NowPlayingActivity>(this, "nowplaying", NowPlayingActivity.class));
        b.addTab(tab, 2, false);
         
    } 
 
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt("tabState", getActionBar().getSelectedTab().getPosition());
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android ActionBar Questions & Answers:

Other Android ActionBar Examples

0:	ActionBar actionBar = getActionBar();
1:	
2:	// set the icon

Read More

0:	ActionBar actionBar = getActionBar();
1:	// hide the action bar
2:	actionBar.hide();

Read More

12:	
13:			// get action bar	
14:			ActionBar actionBar = getActionBar();
15:	
16:			// Enabling Up / Back navigation

Read More

See Code Examples for Android ActionBar Methods: