Example usage for android.widget TabWidget getChildCount

List of usage examples for android.widget TabWidget getChildCount

Introduction

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

Prototype

public int getChildCount() 

Source Link

Document

Returns the number of children in the group.

Usage

From source file:Main.java

public static void setTabWidgetTitle(TabWidget tabWidget, int size) {
    for (int i = 0, count = tabWidget.getChildCount(); i < count; i++) {
        ((TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title)).setTextSize(size);
    }/*from  ww w .j a v a 2  s.  c  o  m*/
}

From source file:Main.java

public static void setTabWidgetTitle(Context context, TabWidget tabWidget, int size, int color) {
    TextView tv = null;//from w w  w.ja va 2s.co m
    for (int i = 0, count = tabWidget.getChildCount(); i < count; i++) {
        tv = ((TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title));
        tv.setTextSize(size);
        tv.getPaint().setFakeBoldText(false);
        tv.setTextColor(context.getResources().getColorStateList(color));
    }
}

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

/**
 * initial tab host/*from   w  w w  .  java 2 s .  c o m*/
 */
@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:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java

static boolean updateButtonBar(Activity a, int highlight) {
    final TabWidget ll = (TabWidget) a.findViewById(R.id.buttonbar);
    boolean withtabs = false;
    Intent intent = a.getIntent();//from   w  w  w  .  ja v  a  2  s.co  m
    if (intent != null) {
        withtabs = intent.getBooleanExtra("withtabs", false);
    }

    if (highlight == 0 || !withtabs) {
        ll.setVisibility(View.GONE);
        return withtabs;
    } else if (withtabs) {
        ll.setVisibility(View.VISIBLE);
    }
    for (int i = ll.getChildCount() - 1; i >= 0; i--) {

        View v = ll.getChildAt(i);
        boolean isActive = (v.getId() == highlight);
        if (isActive) {
            ll.setCurrentTab(i);
            sActiveTabIndex = i;
        }
        v.setTag(i);
        v.setOnFocusChangeListener(new View.OnFocusChangeListener() {

            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    for (int i = 0; i < ll.getTabCount(); i++) {
                        if (ll.getChildTabViewAt(i) == v) {
                            ll.setCurrentTab(i);
                            processTabClick((Activity) ll.getContext(), v,
                                    ll.getChildAt(sActiveTabIndex).getId());
                            break;
                        }
                    }
                }
            }
        });

        v.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                processTabClick((Activity) ll.getContext(), v, ll.getChildAt(sActiveTabIndex).getId());
            }
        });
    }
    return withtabs;
}

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

/**
 * initial tab host/*from  w  ww  .jav  a2 s  .  c  om*/
 */
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/*from   w  ww  .  j a  va 2  s.  c o 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<<");
    }
}