Profile
Pastes: 74486
Members: 1447

Paste

Plain view | 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 ( 3 years ago )

  1. package ml.ml;
  2.  
  3.  
  4.  
  5. import android.app.Activity;
  6. import android.app.TabActivity;
  7. import android.content.Intent;
  8. import android.content.res.Resources;
  9. import android.os.Bundle;
  10. import android.view.Window;
  11. import android.widget.TabHost;
  12.  
  13. public class tabview extends TabActivity {
  14.   Bundle tab_intent;
  15.   public static String name, from;
  16.     /** Called when the activity is first created. */
  17.     @Override
  18.     public void onCreate(Bundle savedInstanceState) {
  19.         super.onCreate(savedInstanceState);
  20.         requestWindowFeature(Window.FEATURE_NO_TITLE);
  21.         setContentView(R.layout.viewtab);
  22.      
  23.         Resources res = getResources(); // Resource object to get Drawables
  24.         TabHost tabHost = getTabHost();  // The activity TabHost
  25.         TabHost.TabSpec spec;  // Resusable TabSpec for each tab
  26.         Intent intent;  // Reusable Intent for each tab
  27.  
  28.         // Create an Intent to launch an Activity for the tab (to be reused)
  29.        
  30.        
  31.  
  32.         // Initialize a TabSpec for each tab and add it to the TabHost
  33.         intent = new Intent().setClass(this, specification.class);
  34.         spec = tabHost.newTabSpec("Spcefication").setIndicator("Spcefication",
  35.                           res.getDrawable(R.drawable.spec1))
  36.                       .setContent(intent);
  37.         tabHost.addTab(spec);
  38.         tabHost.setCurrentTab(2);
  39.         // Do the same for the other tabs
  40.         intent = new Intent().setClass(this, audio.class);
  41.         spec = tabHost.newTabSpec("Gallery").setIndicator("Images",
  42.                           res.getDrawable(R.drawable.ima))
  43.                       .setContent(intent);
  44.         tabHost.addTab(spec);
  45.  
  46.         intent = new Intent().setClass(this, video.class);
  47.         spec = tabHost.newTabSpec("Videos").setIndicator("Videos",
  48.                 res.getDrawable(R.drawable.videoicon))
  49.             .setContent(intent);
  50. tabHost.addTab(spec);
  51.        
  52.     }}

Revise this Paste
Your Name:
Code Language:
 
Security Image:
Text seen in Image:
Comments

Nothing has been added as yet. Post a comment.