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

This code example shows how to use the following methods:getCurrentTab
        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 
     * 
     * @return pager adapter 
     */ 
    protected abstract V createAdapter(); 
 
7
CodeRank
This code example shows how to use the following methods:getCurrentTab
            return Fragment.instantiate(mContext, info.clss.getName(), info.args);
        } 
 
        @Override 
        public void onTabChanged(String tabId) {
            int position = mTabHost.getCurrentTab();
            mViewPager.setCurrentItem(position);
        } 
 
        @Override 
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        } 
 
        @Override 
        public void onPageSelected(int position) {
            // 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. 
7
CodeRank
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
This code example shows how to use the following methods:getCurrentTab, setCurrentTab, setCurrentTabByTag
     @Override 
     protected void onRestoreInstanceState(Bundle state) {
         super.onRestoreInstanceState(state);
         String cur = state.getString("currentTab");
         if (cur != null) {
             mTabHost.setCurrentTabByTag(cur);
         } 
         if (mTabHost.getCurrentTab() < 0) {
             if (mDefaultTab != null) {
                 mTabHost.setCurrentTabByTag(mDefaultTab);
             } else if (mDefaultTabIndex >= 0) {
                 mTabHost.setCurrentTab(mDefaultTabIndex);
             } 
         } 
     } 
 
     @Override 
     protected void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
         String currentTabTag = mTabHost.getCurrentTabTag();
6
CodeRank
This code example shows how to use the following methods:getCurrentTab
		return Fragment.instantiate(mContext, info.clss.getName(), info.args);
	} 
 
	@Override 
	public void onTabChanged(String tabId) {
		int position = mTabHost.getCurrentTab();
		mViewPager.setCurrentItem(position);
	} 
 
	@Override 
	public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
	} 
 
	@Override 
	public void onPageSelected(int position) {
		mTabHost.setCurrentTab(position);
	} 
 
	@Override 
	public void onPageScrollStateChanged(int state) {
5
CodeRank
This code example shows how to use the following methods:getCurrentTab
 
	 
	@Override 
	public void onTabChanged(String tabId)
	{ 
		int position = mTabHost.getCurrentTab();
		mViewPager.setCurrentItem(position);
	} 
 
 
	@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);
	} 
5
CodeRank
This code example shows how to use the following methods:getCurrentTab, getCurrentView
    } 
    private int lastTab = 3;
    private View lastTabView;
 
    public void onTabChanged(String tabId) {
        if (lastTab == tabHost.getCurrentTab()) {
            return; 
        } 
        if (((LiqoidApplication) getApplication()).getGlobalPreferences().getBoolean("animations", false)) {
            if (lastTab > tabHost.getCurrentTab()) {
                tabHost.getCurrentView().setAnimation(inFromLeftAnimation());
                lastTabView.setAnimation(outToRightAnimation());
 
            } else { 
                tabHost.getCurrentView().setAnimation(inFromRightAnimation());
                lastTabView.setAnimation(outToLeftAnimation());
 
            } 
        } 
        lastTab = tabHost.getCurrentTab();

5
CodeRank
This code example shows how to use the following methods:getCurrentTab
            return Fragment.instantiate(mContext, info.clss.getName(), info.args);
        } 
 
        @Override 
        public void onTabChanged(String tabId) {
            int position = mTabHost.getCurrentTab();
            mViewPager.setCurrentItem(position);
        } 
 
        @Override 
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        } 
 
        @Override 
        public void onPageSelected(int position) {
            mTabHost.setCurrentTab(position);
        } 
 
        @Override 
        public void onPageScrollStateChanged(int state) {
5
CodeRank
This code example shows how to use the following methods:getCurrentTab, getTabWidget
        tabHost.addTab(searchspec); // Adding search tab
        setTabColor(tabHost);
        tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener(){
        	  @Override 
        	  public void onTabChanged(String tabId) {
        	    int tab = tabHost.getCurrentTab();
        	    tabHost.getTabWidget().getChildAt(tab).setBackgroundColor(Color.parseColor("#FFFFFF"));
        	    setTabColor(tabHost);
        	  } 
        	}); 
         
         
    } 
     
    public static void setTabColor(TabHost tabhost) {
        for(int i=0;i<tabhost.getTabWidget().getChildCount();i++)
        { 
            tabhost.getTabWidget().getChildAt(i).setBackgroundColor(Color.WHITE); //unselected
        } 
        tabhost.getTabWidget().getChildAt(tabhost.getCurrentTab()).setBackgroundColor(Color.parseColor("#FFFFFF")); // selected
5
CodeRank
This code example shows how to use the following methods:getCurrentTab, getCurrentTabView, setCurrentTab
	} 
 
	// "Boss, we really cannot delete one a'dem tab gubbinz, so we hides 'em." 
	private void deleteTab()  
	{ 
		int position = tabHost.getCurrentTab();
		Log.d("Position", Integer.toString(position));
		 
		Log.d("Z val in delete()", Integer.toString(z));
		 
		tabHost.getCurrentTabView().setVisibility(View.GONE);
 
		if (position > 0)
		{ 
			tabHost.setCurrentTab(position + 1);
			 
			z -= 1;
			 
			if (z < 0)
			{ 

5
CodeRank

Related TabHost getCurrentTab Questions & Answers:

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