Example usage for android.widget TabWidget removeView

List of usage examples for android.widget TabWidget removeView

Introduction

In this page you can find the example usage for android.widget TabWidget removeView.

Prototype

@Override
public void removeView(View view) 

Source Link

Document

Note: do not invoke this method from #draw(android.graphics.Canvas) , #onDraw(android.graphics.Canvas) , #dispatchDraw(android.graphics.Canvas) or any related method.

Usage

From source file:com.example.tabstemplate.MainActivity.java

/**
 * initial tab host/*  www  . j a  va  2s .  c om*/
 */
@SuppressLint("NewApi")
private void initTab() {
    Log.d(TAG, "initTab>>");
    final TabWidget tabWidget = (TabWidget) getLayoutInflater().inflate(R.layout.buttonbar, null);
    mTabCount = tabWidget.getChildCount();
    View tabView;
    for (int i = 0; i < mTabCount; i++) {
        tabView = tabWidget.getChildAt(0);
        if (tabView != null) {
            tabWidget.removeView(tabView);
        }
        Log.d(TAG, "addTab:" + i);
        mTabHost.addTab(
                mTabHost.newTabSpec(getStringId(i)).setIndicator(tabView).setContent(android.R.id.tabcontent));
    }
    Log.d(TAG, "initTab<<");
}

From source file:com.custom.music.MusicBrowserActivity.java

/**
 * initial tab host//from w  w  w. j ava  2 s .co m
 */
private void initTab() {
    Log.i(TAG, ">>> initTab", Log.APP);
    final TabWidget tabWidget = (TabWidget) getLayoutInflater().inflate(R.layout.buttonbar, null);
    mOrientaiton = getResources().getConfiguration().orientation;
    mTabCount = tabWidget.getChildCount();
    View tabView;
    /// M:remove fake menu
    if (mHasMenukey) {
        mTabCount--;
    }
    for (int i = 0; i < mTabCount; i++) {
        tabView = tabWidget.getChildAt(0);
        if (tabView != null) {
            tabWidget.removeView(tabView);
        }
        Log.i(TAG, "addTab:" + i, Log.APP);
        mTabHost.addTab(
                mTabHost.newTabSpec(getStringId(i)).setIndicator(tabView).setContent(android.R.id.tabcontent));
    }
    if (mOrientaiton == Configuration.ORIENTATION_PORTRAIT) {
        TabWidget tabWidgetTemp = mTabHost.getTabWidget();
        //update by zjw
        //PLAYBACK_INDEX
        for (int i = 0; i < mTabCount; i++) {
            tabView = tabWidgetTemp.getChildTabViewAt(i);
            if (tabView != null) {
                tabView.setVisibility(View.GONE);
            }
            Log.i(TAG, "set tab gone:" + i, Log.APP);
        }
    }
    Log.i(TAG, "initTab >>>", Log.APP);
}

From source file:com.android.music.MusicBrowserActivity.java

/**
 * initial tab host/* w w w . j  a v a2  s  . co  m*/
 */
private void initTab() {
    if (mPermissionReqProcessed == true) {
        MusicLogUtils.d(TAG, "initTab>>");
        final TabWidget tabWidget = (TabWidget) getLayoutInflater().inflate(R.layout.buttonbar, null);
        mOrientaiton = getResources().getConfiguration().orientation;
        mTabCount = tabWidget.getChildCount();
        View tabView;
        /// M:remove fake menu
        if (mHasMenukey) {
            mTabCount--;
        }
        for (int i = 0; i < mTabCount; i++) {
            tabView = tabWidget.getChildAt(0);
            if (tabView != null) {
                tabWidget.removeView(tabView);
            }
            MusicLogUtils.d(TAG, "addTab:" + i);
            mTabHost.addTab(mTabHost.newTabSpec(getStringId(i)).setIndicator(tabView)
                    .setContent(android.R.id.tabcontent));
        }
        if (mOrientaiton == Configuration.ORIENTATION_PORTRAIT) {
            TabWidget tabWidgetTemp = mTabHost.getTabWidget();
            for (int i = PLAYBACK_INDEX; i < mTabCount; i++) {
                tabView = tabWidgetTemp.getChildTabViewAt(i);
                if (tabView != null) {
                    tabView.setVisibility(View.GONE);
                }
                MusicLogUtils.d(TAG, "set tab gone:" + i);
            }
        }
        MusicLogUtils.d(TAG, "initTab<<");
    }
}