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

This code example shows how to use the following methods:setOnTabChangedListener
        public TabsAdapter(FragmentActivity activity, TabHost tabHost, ViewPager pager) {
            super(activity.getSupportFragmentManager());
            mContext = activity;
            mTabHost = tabHost;
            mViewPager = pager;
            mTabHost.setOnTabChangedListener(this);
            mViewPager.setAdapter(this);
            mViewPager.setOnPageChangeListener(this);
        } 
 
        public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
            tabSpec.setContent(new DummyTabFactory(mContext));
            String tag = tabSpec.getTag();
 
            TabInfo info = new TabInfo(tag, clss, args);
            mTabs.add(info);
            mTabHost.addTab(tabSpec);
            notifyDataSetChanged(); 
        } 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  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
Contextual code suggestions in your IDE  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
Contextual code suggestions in your IDE  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
Contextual code suggestions in your IDE  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
Contextual code suggestions in your IDE  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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addTab, newTabSpec, setCurrentTab, setOnTabChangedListener
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
Contextual code suggestions in your IDE  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
Contextual code suggestions in your IDE  Get Codota for Java

Related TabHost setOnTabChangedListener Questions & Answers:

setOnTabChangedListener Method Overview
Register a callback to be invoked when the selected state of any of the items in this list changes
See Code Examples for other Android TabHost Methods: