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

This code example shows how to use the following methods:addTab
            tabSpec.setContent(new DummyTabFactory(mContext));
            String tag = tabSpec.getTag();
 
            TabInfo info = new TabInfo(tag, clss, args);
            mTabs.add(info);
            mTabHost.addTab(tabSpec);
            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);
        } 
 
7
CodeRank
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);

7
CodeRank
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
This code example shows how to use the following methods:addTab, clearAllTabs, newTabSpec
 
	private void setupTabs() { 
		Intent projects = new Intent(this, Projects.class);
		Intent activities = new Intent(this, Activities.class);
 
		tabHost.clearAllTabs();
 
		tabHost.addTab(tabHost.newTabSpec("tab_projects")
				.setIndicator("My Projects")
				.setContent(projects));
 
		tabHost.addTab(tabHost.newTabSpec("tab_activities")
				.setIndicator("Activity Feed")
				.setContent(activities));
 
	} 
} 
7
CodeRank
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
This code example shows how to use the following methods:addTab, newTabSpec, setCurrentTab
  private String serialid;
 
  public void addTab() 
  { 
    this.mTabHost = getTabHost();
    TabHost.TabSpec localTabSpec1 = this.mTabHost.newTabSpec("BrandGoodReputationActivity");
    Intent localIntent1 = new Intent(this, BrandGoodReputationActivity.class);
    localIntent1.putExtra("serialid", this.serialid);
    localTabSpec1.setContent(localIntent1);
    localTabSpec1.setIndicator("", getResources().getDrawable(2130837733));
    this.mTabHost.addTab(localTabSpec1);
    TabHost.TabSpec localTabSpec2 = this.mTabHost.newTabSpec("BrandNeutralReputationActivity");
    Intent localIntent2 = new Intent(this, BrandNeutralReputationActivity.class);
    localIntent2.putExtra("serialid", this.serialid);
    localTabSpec2.setContent(localIntent2);
    localTabSpec2.setIndicator("", getResources().getDrawable(2130837733));
    this.mTabHost.addTab(localTabSpec2);
    TabHost.TabSpec localTabSpec3 = this.mTabHost.newTabSpec("BrandBadReputationActivity");
    Intent localIntent3 = new Intent(this, BrandBadReputationActivity.class);
    localIntent3.putExtra("serialid", this.serialid);

6
CodeRank
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
This code example shows how to use the following methods:addTab, newTabSpec, setCurrentTab
 
		super.onCreate(savedInstanceState);
 
		tabHost = getTabHost();
 
		tabHost.addTab(tabHost
				.newTabSpec(eu.fbk.dycapo.activities.Settings.TAB_TAGS[0])
				.setContent(new Intent(this, Me.class))
				.setIndicator(
						eu.fbk.dycapo.activities.Settings.TAB_TAGS[0],
						getResources().getDrawable(
								android.R.drawable.ic_menu_info_details)));
		tabHost.addTab(tabHost
				.newTabSpec(eu.fbk.dycapo.activities.Settings.TAB_TAGS[1])
				.setContent(new Intent(this, Prefs.class))
				.setIndicator(
						eu.fbk.dycapo.activities.Settings.TAB_TAGS[1],
						getResources().getDrawable(
								android.R.drawable.ic_menu_preferences)));
		tabHost.addTab(tabHost

6
CodeRank
This code example shows how to use the following methods:addTab, newTabSpec
 
        // create intent to be invoked on tab press 
        final Intent intent = new Intent().setClass(context, activityClass);
 
        // init TabSpec 
        final TabHost.TabSpec tabSpec = tabHost.newTabSpec(tabId).setIndicator(context.getString(tabCaptionId)).setContent(intent);
 
        tabHost.addTab(tabSpec);
    } 
 
    public static int toPixels(@Nonnull DisplayMetrics dm, float dps) {
        final float scale = dm.density;
        return (int) (dps * scale + 0.5f);
    } 
 
    public static int getScreenOrientation(@Nonnull Activity activity) {
        final Display display = activity.getWindowManager().getDefaultDisplay();
 
        final int result;
 
6
CodeRank
This code example shows how to use the following methods:addTab, newTabSpec, setCurrentTabByTag
    super.onCreate(paramBundle);
    requestWindowFeature(1);
    setContentView(2130903104);
    this.b = ((RadioGroup)findViewById(2131231031));
    this.c = getTabHost();
    this.c.addTab(this.c.newTabSpec("tab1").setIndicator(getString(2131429126)).setContent(new Intent(this, SoftwareManager2.class)));
    this.c.addTab(this.c.newTabSpec("tab2").setIndicator(getString(2131429127)).setContent(new Intent(this, APKManagerActivity.class)));
    this.b.setOnCheckedChangeListener(new aw(this));
    this.c.setCurrentTabByTag("tab1");
    ((RadioButton)findViewById(2131231032)).setChecked(true);
  } 
} 
 
/* Location:           C:\Users\sandrocheng.21KUNPENG\Desktop\classes_dex2jar\ 
 * Qualified Name:     com.keniu.security.software.SoftwareManagerTabActivity 
 * JD-Core Version:    0.6.2 
 */ 
6
CodeRank

Related TabHost addTab Questions & Answers:

Other TabHost addTab Examples

35:	        
36:	        // Adding all TabSpec to TabHost
37:	        tabHost.addTab(photospec); // Adding photos tab
38:	        tabHost.addTab(songspec); // Adding songs tab
39:	        tabHost.addTab(videospec); // Adding videos tab
-
36:	        // Adding all TabSpec to TabHost
37:	        tabHost.addTab(photospec); // Adding photos tab
38:	        tabHost.addTab(songspec); // Adding songs tab
39:	        tabHost.addTab(videospec); // Adding videos tab
40:	    }
-
37:	        tabHost.addTab(photospec); // Adding photos tab
38:	        tabHost.addTab(songspec); // Adding songs tab
39:	        tabHost.addTab(videospec); // Adding videos tab
40:	    }
41:	}

Read More

40:	        
41:	        // Adding all TabSpec to TabHost
42:	        tabHost.addTab(inboxSpec); // Adding Inbox tab
43:	        tabHost.addTab(outboxSpec); // Adding Outbox tab
44:	        tabHost.addTab(profileSpec); // Adding Profile tab
-
41:	        // Adding all TabSpec to TabHost
42:	        tabHost.addTab(inboxSpec); // Adding Inbox tab
43:	        tabHost.addTab(outboxSpec); // Adding Outbox tab
44:	        tabHost.addTab(profileSpec); // Adding Profile tab
45:	    }
-
42:	        tabHost.addTab(inboxSpec); // Adding Inbox tab
43:	        tabHost.addTab(outboxSpec); // Adding Outbox tab
44:	        tabHost.addTab(profileSpec); // Adding Profile tab
45:	    }
46:	}

Read More

addTab Method Overview
Add a tab.
See Code Examples for other Android TabHost Methods: