ActionBar newTab - 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 newTab method.

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: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, 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());
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
This code example shows how to use the following methods:newTab, setDisplayShowHomeEnabled, setDisplayShowTitleEnabled, setNavigationMode, setSelectedNavigationItem
        mViewPager.setId(1234);
        setContentView(mViewPager);
 
        // setup action bar for tabs 
        ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayShowHomeEnabled(false);
 
        mTabsAdapter = new TabsAdapter(this, mViewPager);
        mTabsAdapter.addTab(actionBar.newTab().setText("home"), HomeFragment.class, null);
        mTabsAdapter.addTab(actionBar.newTab().setText("friends"), FriendsListFragment.class, null);
        mTabsAdapter.addTab(actionBar.newTab().setText("about"), AboutFragment.class, null);
 
        // check for last open tab 
        if (savedInstanceState != null) {
            actionBar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
        } 
    } 
 

6
CodeRank
This code example shows how to use the following methods:addTab, newTab, setDisplayShowHomeEnabled, setDisplayShowTitleEnabled, setNavigationMode
        } 
    } 
     
    public void loadActionBar(){ 
  	  ActionBar actionBar = getActionBar();
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
         
        Tab tab = actionBar
                .newTab()
                .setText("Schedule")
                .setTabListener(new DialogNavTabListener<ScheduleFragment>(this, "schedule", ScheduleFragment.class));
        actionBar.addTab(tab);
         
        tab = actionBar
                .newTab()
                .setText("Courses")
                .setTabListener(new NavTabListener<CourseFragment>(this, "courses", CourseFragment.class));
        actionBar.addTab(tab);

6
CodeRank
This code example shows how to use the following methods:addTab, newTab, setDisplayShowTitleEnabled, setNavigationMode
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.setDisplayShowTitleEnabled(false);
 
        ActionBar.Tab tab = actionBar.newTab()
                .setText("Images")
                .setTabListener(new TabListener<ImagesFragment>(this, "Images", ImagesFragment.class));
        actionBar.addTab(tab);
 
        tab = actionBar.newTab()
                .setText("Settings")
                .setTabListener(new TabListener<SettingsFragment>(this, "Settings", SettingsFragment.class));
        actionBar.addTab(tab);
 
    } 
 

6
CodeRank
This code example shows how to use the following methods:addTab, newTab, setNavigationMode, setTitle
		workwithTabbedActionBar(); 
	} 
 
	public void workwithTabbedActionBar() { 
		ActionBar bar = this.getActionBar();
		bar.setTitle(tag);
		bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
 
		TabListener tl = new TabListener(this, this);
 
		Tab tab1 = bar.newTab();
		tab1.setText("Tab1");
		tab1.setTabListener(tl);
		bar.addTab(tab1);
 
		Tab tab2 = bar.newTab();
		tab2.setText("Tab2");
		tab2.setTabListener(tl);
		bar.addTab(tab2);
	} 

6
CodeRank
This code example shows how to use the following methods:addTab, newTab, setNavigationMode, setTitle
		workwithStandardActionBar(); 
	} 
 
	public void workwithStandardActionBar() { 
		ActionBar bar = this.getActionBar();
		bar.setTitle(tag);
		bar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
		// test to see what happens if you were to attach tabs 
		attachTabs(bar);
	} 
 
	public void attachTabs(ActionBar bar) {
		TabListener tl = new TabListener(this, this);
 
		Tab tab1 = bar.newTab();
		tab1.setText("Tab1");
		tab1.setTabListener(tl);
		bar.addTab(tab1);
 
		Tab tab2 = bar.newTab();

6
CodeRank
This code example shows how to use the following methods:addTab, getTabCount, newTab, setDisplayOptions, setDisplayShowTitleEnabled
	public void onActivityCreated(Bundle savedInstanceState) {
		Log.i("OrderInfoFragment","onActivityCreated");
		activity = getActivity();
//		closeSoftInput(); 
		ActionBar actionBar = activity.getActionBar();
		actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE);
		actionBar.setDisplayShowTitleEnabled(false);
		actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
		currentFragment = this;
		if(actionBar.getTabCount() == 0){
			    if(noCompletedTab == null){
			    	noCompletedTab = actionBar.newTab()
				            .setText("未完成订单")
				            .setTabListener(this);
			    	completedTab = actionBar.newTab()
					        .setText("已完成订单")
					        .setTabListener(this);
			    } 
			    actionBar.addTab(noCompletedTab);
			    actionBar.addTab(completedTab);

6
CodeRank
newTab Method Overview
Create and return a new ActionBar.Tab.
See Code Examples for other Android ActionBar Methods: