Example usage for android.widget TabWidget getChildAt

List of usage examples for android.widget TabWidget getChildAt

Introduction

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

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position 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 w w w .  j a  v a 2s .co  m
}

From source file:Main.java

public static void setTabWidgetTitle(Context context, TabWidget tabWidget, int size, int color) {
    TextView tv = null;/*from w ww. jav a 2 s  .c o 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/*  ww  w  . j  av a2s  .co 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:org.smap.smapTask.android.activities.MainTabsActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // must be at the beginning of any activity that can be called from an external intent
    try {//from   w  w w. j  a  v  a 2  s  . c  o  m
        Collect.createODKDirs();
    } catch (RuntimeException e) {
        createErrorDialog(e.getMessage(), true);
        return;
    }

    setContentView(R.layout.main_tabs);

    Resources res = getResources(); // Resource object to get Drawables
    TabHost tabHost = getTabHost(); // The activity TabHost
    TabHost.TabSpec spec;
    Intent intent;

    tabHost.setBackgroundColor(Color.WHITE);
    tabHost.getTabWidget().setBackgroundColor(Color.DKGRAY);

    // Initialise a TabSpec and intent for each tab and add it to the TabHost
    intent = new Intent().setClass(this, MainListActivity.class);
    spec = tabHost.newTabSpec("taskList").setIndicator(getString(R.string.smap_taskList)).setContent(intent);
    tabHost.addTab(spec);

    /*
     * Initialise a Map tab
     */
    Log.i("trial", "Creating Maps Activity");
    intent = new Intent().setClass(this, MapsActivity.class);
    spec = tabHost.newTabSpec("taskMap").setIndicator(getString(R.string.smap_taskMap)).setContent(intent);
    tabHost.addTab(spec);

    // hack to set font size
    LinearLayout ll = (LinearLayout) tabHost.getChildAt(0);
    TabWidget tw = (TabWidget) ll.getChildAt(0);

    int fontsize = Collect.getQuestionFontsize();

    ViewGroup rllf = (ViewGroup) tw.getChildAt(0);
    mTVFF = getTextViewChild(rllf);
    if (mTVFF != null) {
        mTVFF.setTextSize(fontsize);
        mTVFF.setTextColor(Color.WHITE);
        mTVFF.setPadding(0, 0, 0, 6);
    }

    ViewGroup rlrf = (ViewGroup) tw.getChildAt(1);
    mTVDF = getTextViewChild(rlrf);
    if (mTVDF != null) {
        mTVDF.setTextSize(fontsize);
        mTVDF.setTextColor(Color.WHITE);
        mTVDF.setPadding(0, 0, 0, 6);
    }

}

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();/*w  w w  . j a  va2  s. c om*/
    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 www .  j a  va 2  s.c  o  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//from  w  w  w .  j av  a2  s .c om
 */
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<<");
    }
}