Edit code: here. | Add this to your website. | Report abuse.
Short URL: http://goo.gl/e5GU7
Pasted as Java by tabview.java on Monday, January 23rd, 2012 10:56pm ( 1 year ago )
- package ml.ml;
- import android.app.Activity;
- import android.app.TabActivity;
- import android.content.Intent;
- import android.content.res.Resources;
- import android.os.Bundle;
- import android.view.Window;
- import android.widget.TabHost;
- public class tabview extends TabActivity {
- Bundle tab_intent;
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.viewtab);
- Resources res = getResources(); // Resource object to get Drawables
- TabHost tabHost = getTabHost(); // The activity TabHost
- TabHost.TabSpec spec; // Resusable TabSpec for each tab
- Intent intent; // Reusable Intent for each tab
- // Create an Intent to launch an Activity for the tab (to be reused)
- // Initialize a TabSpec for each tab and add it to the TabHost
- intent = new Intent().setClass(this, specification.class);
- spec = tabHost.newTabSpec("Spcefication").setIndicator("Spcefication",
- res.getDrawable(R.drawable.spec1))
- .setContent(intent);
- tabHost.addTab(spec);
- tabHost.setCurrentTab(2);
- // Do the same for the other tabs
- intent = new Intent().setClass(this, audio.class);
- spec = tabHost.newTabSpec("Gallery").setIndicator("Images",
- res.getDrawable(R.drawable.ima))
- .setContent(intent);
- tabHost.addTab(spec);
- intent = new Intent().setClass(this, video.class);
- spec = tabHost.newTabSpec("Videos").setIndicator("Videos",
- res.getDrawable(R.drawable.videoicon))
- .setContent(intent);
- tabHost.addTab(spec);
- }}