Code example for TabWidget

Methods: getChildAtgetChildCount

0
        // 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;
        } 
    } 
     
    @Override 
    public void onTabChanged(String tabId) {
        Tab newTab = mTabList.get(tabId);
        FragmentTransaction ft = mActivity.getSupportFragmentManager().beginTransaction();
 
        // Determine what event to trigger based on the previously selected tab and the newly selected one. 
        if (mLastTab != newTab) {
            if (mLastTab != null) {
                // Unselect last tab. 
                if (mLastTab.getFragment() != null) {
                    mLastTab.getListener().onTabUnselected(mLastTab, ft);