Example usage for android.widget TabHost addTab

List of usage examples for android.widget TabHost addTab

Introduction

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

Prototype

public void addTab(TabSpec tabSpec) 

Source Link

Document

Add a tab.

Usage

From source file:com.appnexus.opensdkapp.MainActivity.java

private static void AddTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec) {
    // Attach a Tab view factory to the spec
    tabSpec.setContent(activity.new TabFactory(activity));
    tabHost.addTab(tabSpec);
}

From source file:in.ac.iiitd.esya.HomeScreenActivity.java

private static void AddTab(HomeScreenActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec,
        TabInfo tabInfo) {/*from  w ww. j a  v  a2s .c  o m*/
    // Attach a Tab view factory to the spec
    tabSpec.setContent(activity.new TabFactory(activity));
    tabHost.addTab(tabSpec);
}

From source file:org.climprpiano.midisheetmusic.ChooseSongActivity.java

@Override
public void onCreate(Bundle state) {
    globalActivity = this;
    super.onCreate(state);

    Bitmap allFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.allfilesicon);
    Bitmap recentFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.recentfilesicon);
    Bitmap browseFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.browsefilesicon);

    final TabHost tabHost = getTabHost();

    tabHost.addTab(tabHost.newTabSpec("All").setIndicator("All", new BitmapDrawable(allFilesIcon))
            .setContent(new Intent(this, AllSongsActivity.class)));

    tabHost.addTab(tabHost.newTabSpec("Recent").setIndicator("Recent", new BitmapDrawable(recentFilesIcon))
            .setContent(new Intent(this, RecentSongsActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

    tabHost.addTab(tabHost.newTabSpec("Browse").setIndicator("Browse", new BitmapDrawable(browseFilesIcon))
            .setContent(new Intent(this, FileBrowserActivity.class)));

    tabHost.setCurrentTab(1);//from w ww . ja  v  a  2  s .  co m
}

From source file:com.midisheetmusic.ChooseSongActivity.java

@Override
public void onCreate(Bundle state) {
    globalActivity = this;
    super.onCreate(state);

    Bitmap allFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.allfilesicon);
    Bitmap recentFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.recentfilesicon);
    Bitmap browseFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.browsefilesicon);

    final TabHost tabHost = getTabHost();

    tabHost.addTab(tabHost.newTabSpec("All").setIndicator("All", new BitmapDrawable(allFilesIcon))
            .setContent(new Intent(this, AllSongsActivity.class)));

    tabHost.addTab(tabHost.newTabSpec("Recent").setIndicator("Recent", new BitmapDrawable(recentFilesIcon))
            .setContent(new Intent(this, RecentSongsActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

    tabHost.addTab(tabHost.newTabSpec("Browse").setIndicator("Browse", new BitmapDrawable(browseFilesIcon))
            .setContent(new Intent(this, FileBrowserActivity.class)));

}

From source file:com.ubundude.timesheet.MainActivity.java

private static void addTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec, TabInfo tabInfo) {
    // Attach a Tab view factory to the spec
    tabSpec.setContent(activity.new TabFactory(activity));
    String tag = tabSpec.getTag();

    // Check to see if we already have a fragment for this tab, probably
    // from a previously saved state.  If so, deactivate it, because our
    // initial state is that a tab isn't shown.
    tabInfo.fragment = activity.getSupportFragmentManager().findFragmentByTag(tag);
    if (tabInfo.fragment != null && !tabInfo.fragment.isDetached()) {
        FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction();
        ft.detach(tabInfo.fragment);/*from w ww  .ja v a2 s .c o  m*/
        ft.commit();
        activity.getSupportFragmentManager().executePendingTransactions();
    }

    tabHost.addTab(tabSpec);
}

From source file:com.midisheetmusicmemo.ChooseSongActivity.java

@Override
public void onCreate(Bundle state) {
    globalActivity = this;
    TommyConfig.init(this);
    super.onCreate(state);

    Bitmap allFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.allfilesicon);
    Bitmap recentFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.recentfilesicon);
    Bitmap browseFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.browsefilesicon);

    final TabHost tabHost = getTabHost();

    tabHost.addTab(tabHost.newTabSpec("All").setIndicator("All", new BitmapDrawable(allFilesIcon))
            .setContent(new Intent(this, AllSongsActivity.class)));

    tabHost.addTab(tabHost.newTabSpec("Recent").setIndicator("Recent", new BitmapDrawable(recentFilesIcon))
            .setContent(new Intent(this, RecentSongsActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

    tabHost.addTab(tabHost.newTabSpec("Browse").setIndicator("Browse", new BitmapDrawable(browseFilesIcon))
            .setContent(new Intent(this, FileBrowserActivity.class)));

}

From source file:com.infine.android.devoxx.ui.MapHotelFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_map_detail, null);

    final Intent intent = BaseActivity.fragmentArgumentsToIntent(getArguments());
    Bundle extras = intent.getExtras();/* w w w  .  ja va 2  s  . com*/
    if (extras != null) {
        startTab = extras.getInt(EXTRA_ROOM);
    }
    TabHost tabHost = (TabHost) mRootView.findViewById(android.R.id.tabhost);
    tabHost.setup();
    tabHost.addTab(tabHost.newTabSpec(TAG_LEVEL_0).setIndicator(buildIndicator(R.string.tab_map_0))
            .setContent(R.id.tab_map_level0));
    tabHost.addTab(tabHost.newTabSpec(TAG_LEVEL_1).setIndicator(buildIndicator(R.string.tab_map_1))
            .setContent(R.id.tab_map_level1));
    tabHost.setCurrentTab(startTab);

    return mRootView;
}

From source file:com.ecml.ChooseSongActivity.java

@Override
public void onCreate(Bundle state) {

    globalActivity = this;
    super.onCreate(state);

    // Set the Action Bar Title of the Activity (corresponding to the first Tab)
    setTitle("ECML: Choose Song");

    Bitmap allFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.allfilesicon);
    Bitmap recentFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.recentfilesicon);
    Bitmap browseFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.browsefilesicon);

    final TabHost tabHost = getTabHost();

    tabHost.addTab(tabHost.newTabSpec("All").setIndicator("All", new BitmapDrawable(allFilesIcon))
            .setContent(new Intent(this, AllSongsActivity.class)));

    tabHost.addTab(tabHost.newTabSpec("Recent").setIndicator("Recent", new BitmapDrawable(recentFilesIcon))
            .setContent(new Intent(this, RecentSongsActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

    tabHost.addTab(tabHost.newTabSpec("Browse").setIndicator("Browse", new BitmapDrawable(browseFilesIcon))
            .setContent(new Intent(this, FileBrowserActivity.class)));

    tabHost.setOnTabChangedListener(this);
}

From source file:org.n52.geoar.data.sos.SOSFeatureVisualization.java

@Override
public View getFeatureView(SpatialEntity2<? extends Geometry> entity, View convertView, ViewGroup parentView,
        Context activityContext) {
    ViewHolder viewHolder;//from ww w  .ja v a  2  s. c o  m

    if (convertView == null) {
        convertView = LayoutInflater.from(activityContext).inflate(R.layout.sos_featureview, null);
        viewHolder = new ViewHolder();

        viewHolder.textViewServiceSensorId = (TextView) convertView.findViewById(R.id.textViewServiceSensorId);
        viewHolder.textViewDescription = (TextView) convertView.findViewById(R.id.textViewDescription);
        viewHolder.textViewName = (TextView) convertView.findViewById(R.id.textViewName);

        viewHolder.sosObservationView = (SOSObservationView) convertView.findViewById(R.id.sosObservationView);
        viewHolder.sosObservationView.setCapabilitiesCallable(viewHolder.capabilitiesCallable);
        viewHolder.sosObservationView.setObservationCallable(viewHolder.observationCallable);
        viewHolder.sosObservationView.setActivityContext(activityContext);

        TabHost tabHost = (TabHost) convertView.findViewById(android.R.id.tabhost);
        tabHost.setup();
        tabHost.addTab(tabHost.newTabSpec("FOI").setIndicator("Feature").setContent(R.id.scrollViewFOI));
        tabHost.addTab(tabHost.newTabSpec("SOS").setIndicator("Observations").setContent(R.id.layoutSOS));

        tabHost.setCurrentTab(0);

        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }

    if (entity instanceof FOI) {
        viewHolder.featureOfInterest = (FOI) entity;
        viewHolder.textViewName.setText(viewHolder.featureOfInterest.name);
        if (viewHolder.featureOfInterest.description != null) {
            viewHolder.textViewDescription.setText(Html.fromHtml(viewHolder.featureOfInterest.description));
        }
        viewHolder.textViewServiceSensorId.setText(viewHolder.featureOfInterest.id);
    }
    return convertView;
}

From source file:com.divergentthoughtsgames.colonies.HowToPlayActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_how_to_play);

    // Parts adapted from 
    // https://github.com/commonsguy/cw-android/blob/master/Fancy/Tab/src/com/commonsware/android/fancy/TabDemo.java
    TabHost tabs = (TabHost) findViewById(R.id.tabhost);
    tabs.setup();//from w w w  .  ja v  a 2  s  . c  o  m

    TabHost.TabSpec spec = tabs.newTabSpec("Overview");
    spec.setContent(R.id.tab1);
    spec.setIndicator("Overview");
    tabs.addTab(spec);

    spec = tabs.newTabSpec("New Colony");
    spec.setContent(R.id.tab2);
    spec.setIndicator("New Colony");
    tabs.addTab(spec);

    spec = tabs.newTabSpec("Goals");
    spec.setContent(R.id.tab3);
    spec.setIndicator("Goals");
    tabs.addTab(spec);
}