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

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 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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) {
        } 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getCurrentTabTag, setCurrentTab
		final boolean recentCallsRequest = Calls.CONTENT_TYPE.equals(intent
				.getType());
 
		// Dismiss menu provided by any children activities 
		Activity activity = getLocalActivityManager().getActivity(
				mTabHost.getCurrentTabTag());
		if (activity != null) {
			activity.closeOptionsMenu();
		} 
 
		// Tell the children activities that they should ignore any possible 
		// saved 
		// state and instead reload their state from the parent's intent 
		intent.putExtra(EXTRA_IGNORE_STATE, true);
 
		// Remember the old manually selected tab index so that it can be 
		// restored if it is 
		// overwritten by one of the programmatic tab selections 
		final int savedTabIndex = mLastManuallySelectedTab;
 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getCurrentTabTag, setCurrentTab
            return; 
        } 
 
        // Dismiss menu provided by any children activities 
        Activity activity = getLocalActivityManager().
                getActivity(mTabHost.getCurrentTabTag());
        if (activity != null) {
            activity.closeOptionsMenu();
        } 
 
        // Tell the children activities that they should ignore any possible saved 
        // state and instead reload their state from the parent's intent 
        intent.putExtra(EXTRA_IGNORE_STATE, true);
 
        // Choose the tab based on the inbound intent 
        String componentName = intent.getComponent().getClassName();
        if (getClass().getName().equals(componentName)) {
            if (recentCallsRequest) {
                mTabHost.setCurrentTab(TAB_INDEX_CALL_LOG);
            } else { 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:clearAllTabs, getCurrentTab, setCurrentTab
 
	 
	@Override 
	protected void onResume() { 
		super.onResume(); 
		int currentTab = mTabHost.getCurrentTab();
		if(mTabHost==null) mTabHost=getTabHost();
		mTabHost.setCurrentTab(0);
		mTabHost.clearAllTabs();
		addTabs(); 
		mTabHost.setCurrentTab(currentTab);
	} 
 
	private void addTabs(){ 
		TabHost.TabSpec spec;  // Resusable TabSpec for each tab
		Intent intent;  // Reusable Intent for each tab
		long millis = new DateTime().getMillis();
 
 
		// Create an Intent to launch an Activity for the tab (to be reused) 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addTab, newTabSpec, setCurrentTab
        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);
        mTabHost.setCurrentTab(1);
    } 
 
    public void TabDial(FragmentTransaction ft) {
        if (mDialFragment == null) {
            mDialFragment = new DialFragment();
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getTabWidget, setCurrentTab
 
	@Override 
	public void onPageSelected(int position)
	{ 
		// 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)
	{ 
 
	} 
 
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related TabHost setCurrentTab Questions & Answers:

setCurrentTab Method Overview
See Code Examples for other Android TabHost Methods: