title: Android Tabs Views
body: <p>I have decided to use views for my tab interface... 
  I follow a tab interface tutorial and the result of this tutorial is 4 tabs without content (text) under my tabs..</p>
  
  <p>I was wondering how views working.. how can I make a method to set content to tab from an another class.. So main.java is my main file with the views (tabs). Tab1.java has google maps navigate code. </p>
  
  <p>How I can invoke the method setupTab and set the navigation function to tab 1.</p>
  
  <p>Here you can see my code:<br />
  Thanks in advance!</p>
  
  <pre><code> package CustomTabs;  
      import android.app.Activity;
      import android.graphics.drawable.Drawable;
      import android.os.Bundle;
      import android.view.View;
      import android.widget.TabHost;
      import android.widget.TextView;
      import android.widget.TabHost.TabContentFactory;
      import android.widget.TabHost.TabSpec;
  
      public class CustomTabs extends Activity {
  
       private TabHost mTabHost;
  
       private void setupTabHost() {
        mTabHost = (TabHost) findViewById(android.R.id.tabhost);
        mTabHost.setup();
       }
  
       /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // construct the tabhost
        setContentView(R.layout.main);
  
        setupTabHost();
  
        setupTab(new TextView(this), "Tab 1", getResources().getDrawable(R.drawable.ic_tab_artists));
        setupTab(new TextView(this), "Tab 2", getResources().getDrawable(R.drawable.ic_tab_artists));
        setupTab(new TextView(this), "Tab 3", getResources().getDrawable(R.drawable.ic_tab_artists));
        setupTab(new TextView(this), "Tab 4", getResources().getDrawable(R.drawable.ic_tab_artists));
        {
         final View v = mTabHost.getTabWidget().getChildAt(0);
         v.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_bg_selector));
         TextView tv = (TextView) v.findViewById(android.R.id.title);
         tv.setTextColor(this.getResources().getColorStateList(R.drawable.tab_text_selector));
        }
        {
         final View v = mTabHost.getTabWidget().getChildAt(1);
         v.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_bg_selector));
         TextView tv = (TextView) v.findViewById(android.R.id.title);
         tv.setTextColor(this.getResources().getColorStateList(R.drawable.tab_text_selector));
        }
        {
         final View v = mTabHost.getTabWidget().getChildAt(2);
         v.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_bg_selector));
         TextView tv = (TextView) v.findViewById(android.R.id.title);
         tv.setTextColor(this.getResources().getColorStateList(R.drawable.tab_text_selector));
        }
        {
         final View v = mTabHost.getTabWidget().getChildAt(3);
         v.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_bg_selector));
         TextView tv = (TextView) v.findViewById(android.R.id.title);
         tv.setTextColor(this.getResources().getColorStateList(R.drawable.tab_text_selector));
        }
  
       }
  
       private void setupTab(final View view, final String tag, Drawable icon) {
        TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tag, icon).setContent(new TabContentFactory() {
         public View createTabContent(String tag) {return view;}
        });
        mTabHost.addTab(setContent);
  
       }
      }
  </code></pre>