2011-06-22 46 views
0

我在我的應用程序的第一個屏幕中有五個選項卡,我希望製表符在整個應用程序中保持一致,意味着當我移動到新的活動時,這些也在該屏幕中可見。請給我一些建議,提前致謝。這裏是標籤代碼如何在Android應用程序中保留製表符

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) 
    intent = new Intent().setClass(this, Home.class); 

    // Initialize a TabSpec for each tab and add it to the TabHost 
    spec = tabHost.newTabSpec("home") 
      .setIndicator("Home", res.getDrawable(R.drawable.select)) 
      .setContent(intent); 
    tabHost.addTab(spec); 
    tabHost.setCurrentTab(0); 

    // Do the same for the other tabs 
    intent = new Intent().setClass(this, Hypnosis.class); 
    spec = tabHost.newTabSpec("hypnosis") 
      .setIndicator("Hypnosis", res.getDrawable(R.drawable.select)) 
      .setContent(intent); 
    tabHost.addTab(spec); 

    intent = new Intent().setClass(this, SelfDevelopment.class); 
    spec = tabHost 
      .newTabSpec("self development") 
      .setIndicator("Self Development", 
        res.getDrawable(R.drawable.select)).setContent(intent); 
    tabHost.addTab(spec); 

    intent = new Intent().setClass(this, Read.class); 
    spec = tabHost.newTabSpec("read") 
      .setIndicator("Read", res.getDrawable(R.drawable.select)) 
      .setContent(intent); 
    tabHost.addTab(spec); 

    intent = new Intent().setClass(this, Faq.class); 
    spec = tabHost.newTabSpec("faq") 
      .setIndicator("FAQ", res.getDrawable(R.drawable.select)) 
      .setContent(intent); 
    tabHost.addTab(spec); 

回答

相關問題