Example usage for android.widget TabHost getChildAt

List of usage examples for android.widget TabHost getChildAt

Introduction

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

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

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 ava 2 s. com
        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);
    }

}