SHARE
TWEET

Untitled

a guest Mar 7th, 2012 125 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class MyTabApp extends TabActivity {
  2.     public void onCreate(Bundle savedInstanceState) {
  3.         super.onCreate(savedInstanceState);
  4.         setContentView(R.layout.main);
  5.  
  6.         TabHost tabHost = getTabHost();
  7.         TabHost.TabSpec spec;
  8.         Intent intent;
  9.        
  10.         ImageView divider = new ImageView(this);
  11.         divider.setImageResource(R.drawable.divider);
  12.         ImageView tab_divider = new ImageView(this);
  13.         tab_divider.setImageResource(R.drawable.divider);
  14.  
  15.        
  16.         intent = new Intent().setClass(this, Page1.class);
  17.         spec = tabHost.newTabSpec("page1").setIndicator(getLayoutInflater().inflate(R.layout.tab1, null))
  18.                       .setContent(intent);
  19.         tabHost.addTab(spec);
  20.        
  21.         tabHost.getTabWidget().addView(divider, LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
  22.        
  23.         intent = new Intent().setClass(this, Page2.class);
  24.         spec = tabHost.newTabSpec("page2").setIndicator(getLayoutInflater().inflate(R.layout.tab2, null))
  25.                       .setContent(intent);
  26.         tabHost.addTab(spec);
  27.  
  28.         tabHost.getTabWidget().addView(tab_divider, LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
  29.        
  30.         intent = new Intent().setClass(this, Page3.class);
  31.         spec = tabHost.newTabSpec("page3").setIndicator(getLayoutInflater().inflate(R.layout.tab3, null))
  32.                       .setContent(intent);
  33.         tabHost.addTab(spec);
  34.  
  35.         tabHost.setCurrentTab(0);
  36.  
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top