Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 1.14 KB  |  hits: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Android: getTabHost() Error
  2. public class AHActivity extends Activity {
  3. /** Called when the activity is first created. */
  4. @Override
  5. public void onCreate(Bundle savedInstanceState) {
  6.     super.onCreate(savedInstanceState);
  7.     setContentView(R.layout.main);
  8.  
  9.     Resources res = getResources(); // Resource object to get Drawables
  10.     TabHost tabHost = getTabHost();  // The activity TabHost
  11.     TabHost.TabSpec spec;  // Resusable TabSpec for each tab
  12.     Intent intent;  // Reusable Intent for each tab
  13.  
  14.     // Create an Intent to launch an Activity for the tab (to be reused)
  15.     intent = new Intent().setClass(this, EvoActivity.class);
  16.  
  17.     // Initialize a TabSpec for each tab and add it to the TabHost
  18.     spec = tabHost.newTabSpec("evolution").setIndicator("Evolution")
  19.                   .setContent(intent);
  20.     tabHost.addTab(spec);
  21.  
  22.     // Do the same for the other tabs
  23.     intent = new Intent().setClass(this, physActivity.class);
  24.     spec = tabHost.newTabSpec("physics").setIndicator("Physics")
  25.                   .setContent(intent);
  26.     tabHost.addTab(spec);
  27.  
  28.     tabHost.setCurrentTab(2);
  29.     }
  30.     }
  31.        
  32. public class AHActivity extends TabActivity {