Android TabHost - 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 TabHost class.

This code example shows how to use the following methods: getTabWidget, setCurrentTab
            // Unfortunately when TabHost changes the current tab, it kindly 
            // also takes care of putting focus on it when not in touch mode. 
            // The jerk. 
            // This hack tries to prevent this from pulling focus out of our 
            // ViewPager. 
            TabWidget widget = mTabHost.getTabWidget();
            int oldFocusability = widget.getDescendantFocusability();
            widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
            mTabHost.setCurrentTab(position);
            widget.setDescendantFocusability(oldFocusability);
        } 
 
        @Override 
        public void onPageScrollStateChanged(int state) {
        } 
    } 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setCurrentTab
 
    @Override 
    public void onPageSelected(final int position) {
        super.onPageSelected(position);
 
        host.setCurrentTab(position);
    } 
 
    @Override 
    public void onTabChanged(String tabId) {
        updateCurrentItem(host.getCurrentTab());
    } 
 
    @Override 
    public View createTabContent(String tag) {
        return ViewUtils.setGone(new View(getApplication()), true);
    } 
 
    /** 
     * Create pager adapter 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addTab, newTabSpec, setOnTabChangedListener, setup
	/** 
	 * Initialise the Tab Host 
	 */ 
	private void initialiseTabHost(Bundle args) {
		mTabHost = (TabHost)findViewById(android.R.id.tabhost);
        mTabHost.setup();
        TabInfo tabInfo = null;
        TabsFragmentActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator("Tab 1"), ( tabInfo = new TabInfo("Tab1", Tab1Fragment.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        TabsFragmentActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator("Tab 2"), ( tabInfo = new TabInfo("Tab2", Tab2Fragment.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        TabsFragmentActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator("Tab 3"), ( tabInfo = new TabInfo("Tab3", Tab3Fragment.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        // Default to first tab 
        this.onTabChanged("Tab1");
        // 
        mTabHost.setOnTabChangedListener(this);
	} 
	 
	/** 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addTab, clearAllTabs, newTabSpec, setCurrentTab
			setExtras(extras, backlog, "backlog");
			setExtras(extras, current, "current");
			setExtras(extras, icebox, "icebox");
		} 
 
		tabHost.clearAllTabs();
		tabHost.addTab(tabHost.newTabSpec("tab_done")
				.setIndicator("Done")
				.setContent(done));
		tabHost.addTab(tabHost.newTabSpec("tab_current")
				.setIndicator("Current")
				.setContent(current));
		tabHost.addTab(tabHost.newTabSpec("tab_backlog")
				.setIndicator("Backlog")
				.setContent(backlog));
		tabHost.addTab(tabHost.newTabSpec("tab_icebox")
				.setIndicator("Icebox")
				.setContent(icebox));
		 
		tabHost.setCurrentTab(1);

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addTab, newTabSpec, setOnTabChangedListener, setup
	/** 
	 * Initialise the Tab Host 
	 */ 
	private void initialiseTabHost(Bundle args) {
		mTabHost = (TabHost)findViewById(android.R.id.tabhost);
        mTabHost.setup();
        TabInfo tabInfo = null;
        TabsViewPagerFragmentActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator("Tab 1"), ( tabInfo = new TabInfo("Tab1", Tab1Fragment.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        TabsViewPagerFragmentActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator("Tab 2"), ( tabInfo = new TabInfo("Tab2", Tab2Fragment.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        TabsViewPagerFragmentActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator("Tab 3"), ( tabInfo = new TabInfo("Tab3", Tab3Fragment.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        // Default to first tab 
        //this.onTabChanged("Tab1"); 
        // 
        mTabHost.setOnTabChangedListener(this);
	} 
	 
	/** 

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android TabHost Questions & Answers:

Other Android TabHost Examples

13:	        setContentView(R.layout.main);
14:	        
15:	        TabHost tabHost = getTabHost();
16:	        
17:	        // Tab for Photos

Read More

17:	        setContentView(R.layout.main);
18:	        
19:	        TabHost tabHost = getTabHost();
20:	        
21:	        // Inbox Tab

Read More

See Code Examples for Android TabHost Methods: