TabHost setup - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:setLayoutParams, addView, setOnTabChangedListener, setup
	 */ 
	@Override 
	public Widget create(Activity activity, int handle)
	{ 
	     // Construct the tab host that fills the whole screen. 
        TabHost tabHost = new TabHost( activity, null );
        tabHost.setLayoutParams(
        		new LinearLayout.LayoutParams(
                        LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT ) );
 
        // Create the visual structure of the tab host 
        LinearLayout tabRootView = createTabRoot( activity );
        tabHost.addView( tabRootView );
 
        // Must be called when using views instead of activities to fill 
        // a tabs content 
        tabHost.setup( );
 
        tabHost.setOnTabChangedListener( new TabChangeListener( handle ) );
 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addTab, newTabSpec, setOnTabChangedListener, setup
    /** 
     * Step 2: Setup TabHost 
     */ 
    private void initialiseTabHost(Bundle args) {
        mTabHost = (TabHost)findViewById(android.R.id.tabhost);
        mTabHost.setup();
        TabInfo tabInfo = null;
        AddGroup.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator("Class"), ( tabInfo = new TabInfo("Tab1", ClassFragment.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        AddGroup.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator("CCA"), ( tabInfo = new TabInfo("Tab2", CCAFragment.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        AddGroup.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator("Others"), ( tabInfo = new TabInfo("Tab3", OthersFragment.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        // Default to first tab 
        this.onTabChanged("Tab1");
        // 
        mTabHost.setOnTabChangedListener(this);
    } 
  
    /** 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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
Connect your IDE to all the code out there  Get Codota for Java
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
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addTab, newTabSpec, setup
		setTabView(); 
	} 
	 
	private void setTabView(){ 
		tabHost = (TabHost)findViewById(android.R.id.tabhost);
		tabHost.setup();
		 
		TabHost.TabSpec spec1 = tabHost.newTabSpec("tag1");
		spec1.setContent(new Intent(this, SmsWatcherActivity.class));
		spec1.setIndicator("HOME");
		 
		tabHost.addTab(spec1);
		 
		TabHost.TabSpec spec2 = tabHost.newTabSpec("tag2");
		spec2.setContent(new Intent(this, SmsListActivity.class));
		spec2.setIndicator("WATCHING LIST");
		 
		tabHost.addTab(spec2);
		 
		TabHost.TabSpec spec3 = tabHost.newTabSpec("tag3");

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addTab, newTabSpec, setCurrentTab, setOnTabChangedListener, setup
        init(); 
    } 
 
    private void init() { 
        mTabHost = (TabHost) findViewById(android.R.id.tabhost);
        mTabHost.setup();
        mTabHost.setOnTabChangedListener(this);
        initTab(); 
    } 
 
    public void initTab() { 
        TabHost.TabSpec dail = mTabHost.newTabSpec(DIAL);
        dail.setIndicator(DIAL);
        dail.setContent(new DummyTabContent(getBaseContext()));
        mTabHost.addTab(dail);
 
        TabHost.TabSpec contacts = mTabHost.newTabSpec(CONTACTS);
        contacts.setIndicator(CONTACTS);
        contacts.setContent(new DummyTabContent(getBaseContext()));
        mTabHost.addTab(contacts);

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addTab, getTabWidget, newTabSpec, setOnTabChangedListener, setup
            mTabHost.setup();
            mTabHost.setOnTabChangedListener(this);
        } 
         
        // Set the tab properties. 
        TabSpec tabSpec = mTabHost.newTabSpec(tag);
        tabSpec.setIndicator(tab.getText());
        tabSpec.setContent(new DummyTabFactory(mActivity));
         
        // Add the tab to the interface. 
        mTabList.put(tag, tab);
        mTabHost.addTab(tabSpec);
         
        // Shorten the tab's height because there is no icon to display. 
        // The tab would display an empty space instead of the icon otherwise. 
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD || Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
            TabWidget widget = mTabHost.getTabWidget();
            int height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 40, mActivity.getResources().getDisplayMetrics());
            RelativeLayout child = (RelativeLayout)widget.getChildAt(widget.getChildCount() - 1);
            child.getLayoutParams().height = height;

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addTab, newTabSpec, setup
	 *  
	 * Initializes or instantiates all tabs.  
	 */ 
	private void initializeTabbedView(){ 
		tabHost = getTabHost();
		tabHost.setup();
		//if(!LoadProject.loadFile_boolean){ 
			instantiateHomeTab(); 
			instantiateProjectTab(); 
			instantiateEnvelopeTab(); 
			instantiateMechanicalTab(); 
			tabHost.addTab(homeTab);
			tabHost.addTab(projectTab);
			tabHost.addTab(envelopeTab);
			tabHost.addTab(mechanicalTab);
		//} 
	} 
	 
	/** 
	 * instantiateHomeTab Method 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addTab, newTabSpec, setOnTabChangedListener, setup
    /** 
     * Step 2: Setup TabHost 
     */ 
    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("Overview"), ( tabInfo = new TabInfo("Tab1", TabFragment1.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        TabsFragmentActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator("Feeds"), ( tabInfo = new TabInfo("Tab2", TabFragment2.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        // Default to first tab 
        this.onTabChanged("Tab1");
        // 
        mTabHost.setOnTabChangedListener(this);
    } 
  
    /** 
     * @param activity 
     * @param tabHost 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addTab, newTabSpec, setOnTabChangedListener, setup
	/** 
	 * Step 2: Setup TabHost 
	 */ 
	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("Add Expense").setIndicator("Add Expense"), ( tabInfo = new TabInfo("Add Expense", 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);
        TabsFragmentActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab4").setIndicator("Tab 4"), ( tabInfo = new TabInfo("Tab4", Tab4Fragment.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);        // Default to first tab
        this.onTabChanged("Add Expense");
        // 
        mTabHost.setOnTabChangedListener(this);
	} 
 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related TabHost setup Questions & Answers:

setup Method Overview
Call setup() before adding tabs if loading TabHost using findViewById().
See Code Examples for other Android TabHost Methods: