Advertisement
Guest User

Untitled

a guest
May 17th, 2011
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.93 KB | None | 0 0
  1. package ywong02.android.HelloTabWidget;
  2.  
  3. import android.app.Activity;
  4. import android.app.TabActivity;
  5. import android.content.Intent;
  6. import android.content.res.Resources;
  7. import android.os.Bundle;
  8. import android.webkit.WebView;
  9. import android.widget.TabHost;
  10. import android.widget.TextView;
  11.  
  12. public class HelloTabWidget extends TabActivity {
  13.    
  14.     WebView mWebView;
  15.     /** Called when the activity is first created. */
  16.     @Override
  17.     public void onCreate(Bundle savedInstanceState) {
  18.         super.onCreate(savedInstanceState);
  19.         setContentView(R.layout.main);
  20.  
  21.         Resources res = getResources(); // Resource object to get Drawables
  22.         TabHost tabHost = getTabHost();  // The activity TabHost
  23.         TabHost.TabSpec spec;  // Reusable TabSpec for each tab
  24.         Intent intent;  // Reusable Intent for each tab
  25.  
  26.         // Create an Intent to launch an Activity for the tab (to be reused)
  27.         intent = new Intent().setClass(this, MyTwitter.class);
  28.  
  29.         // Initialize a TabSpec for each tab and add it to the TabHost
  30.         spec = tabHost.newTabSpec("artists").setIndicator("Artists",
  31.                           res.getDrawable(R.drawable.ic_tab_artists))
  32.                       .setContent(intent);
  33.         tabHost.addTab(spec);
  34.  
  35.         // Do the same for the other tabs
  36.         intent = new Intent().setClass(this, AlbumsActivity.class);
  37.         spec = tabHost.newTabSpec("albums").setIndicator("Albums",
  38.                           res.getDrawable(R.drawable.ic_tab_albums))
  39.                       .setContent(intent);
  40.         tabHost.addTab(spec);
  41.  
  42.         intent = new Intent().setClass(this, SongsActivity.class);
  43.         spec = tabHost.newTabSpec("songs").setIndicator("Songs",
  44.                           res.getDrawable(R.drawable.ic_tab_songs))
  45.                       .setContent(intent);
  46.         tabHost.addTab(spec);
  47.  
  48.         tabHost.setCurrentTab(0);  // default tab choice (0,1,2,...)
  49.     }
  50.    
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement