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

This code example shows how to use the following methods:addTab
        public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
            TabInfo info = new TabInfo(clss, args);
            tab.setTag(info);
            tab.setTabListener(this);
            mTabs.add(info);
            mActionBar.addTab(tab);
            notifyDataSetChanged(); 
        } 
 
        @Override 
        public int getCount() { 
            return mTabs.size();
        } 
 
        @Override 
        public Fragment getItem(int position) {
            TabInfo info = mTabs.get(position);
            return Fragment.instantiate(mContext, info.clss.getName(), info.args);
        } 
 
6
CodeRank
This code example shows how to use the following methods:addTab
        public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
            TabInfo info = new TabInfo(clss, args);
            tab.setTag(info);
            tab.setTabListener(this);
            mTabs.add(info);
            mActionBar.addTab(tab);
            notifyDataSetChanged(); 
        } 
 
        @Override 
        public int getCount() { 
            return mTabs.size();
        } 
 
        @Override 
        public Fragment getItem(int position) {
            TabInfo info = mTabs.get(position);
            return Fragment.instantiate(mContext, info.clss.getName(), info.args);
        } 
 
6
CodeRank
This code example shows how to use the following methods:addTab
        public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
            TabInfo info = new TabInfo(clss, args);
            tab.setTag(info);
            tab.setTabListener(this);
            mTabs.add(info);
            mActionBar.addTab(tab);
            notifyDataSetChanged(); 
        } 
 
        @Override 
        public int getCount() { 
            return mTabs.size();
        } 
 
        @Override 
        public Fragment getItem(int position) {
            TabInfo info = mTabs.get(position);
            if (info.fragment == null) {
                info.fragment = Fragment.instantiate(mContext, info.clss.getName(), info.args);
            } 
6
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: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
        public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
            TabInfo info = new TabInfo(clss, args);
            tab.setTag(info);
            tab.setTabListener(this);
            mTabs.add(info);
            mActionBar.addTab(tab);
            notifyDataSetChanged(); 
        } 
 
        @Override 
        public int getCount() { 
            return mTabs.size();
        } 
 
        @Override 
        public Fragment getItem(int position) {
            TabInfo info = mTabs.get(position);
            return Fragment.instantiate(mContext, info.clss.getName(), info.args);
        } 
 
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, 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
This code example shows how to use the following methods:addTab
        public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
            TabInfo info = new TabInfo(clss, args);
            tab.setTag(info);
            tab.setTabListener(this);
            mTabs.add(info);
            mActionBar.addTab(tab);
            notifyDataSetChanged(); 
        } 
 
        @Override 
        public int getCount() { 
            return mTabs.size();
        } 
 
        @Override 
        public Fragment getItem(int position) {
            TabInfo info = mTabs.get(position);
            return Fragment.instantiate(mContext, info.clss.getName(), info.args);
        } 
 
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
addTab Method Overview
Add a tab for use in tabbed navigation mode.
See Code Examples for other Android ActionBar Methods: