2012-02-09 12 views
1

こんにちは私はアプリケーションを作成しています。ここではすべてのアクティビティにTabBarを表示する必要があります。私は4つのタブを使用してTabBarの底を設定しました。 home, contact, about and call us
ホームのタブにはいくつかのボタンがあります。その時間内に任意のボタンをクリックすると、他のアクティビティを移動する必要があります。インテントを使用して別のアクティビティに移動しましたが、ここでTabBarは表示されませんでした。ただし、すべてのアクティビティで同じTabBarを表示する必要があります。誰かがこれを行う方法を知っている場合、私に解決策を提案してください。アンドロイドのアプリ全体にタブバーを表示するには?

 DefenceLaywer.java: 
     public class DefenceLaywer extends TabActivity { 

     TabHost tabhost; 
     @Override 
     public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     tabhost = (TabHost)findViewById(android.R.id.tabhost); 
     TabSpec firstTabSpec = tabhost.newTabSpec("Home"); 
     TabSpec secondTabSpec = tabhost.newTabSpec("Claimonline"); 
     TabSpec thirdTabSpec = tabhost.newTabSpec("CallUs"); 
     TabSpec fourthTabSpec = tabhost.newTabSpec("AboutUs"); 

//  TabSpec thirdTabSpec = tabhost.newTabSpec("Interactive"); 
     firstTabSpec.setIndicator("Home", getResources().getDrawable(R.drawable.home)); 
     secondTabSpec.setIndicator("ContactUs", getResources().getDrawable(R.drawable.contactus)); 
     thirdTabSpec.setIndicator("CallUs", getResources().getDrawable(R.drawable.callus)); 
     fourthTabSpec.setIndicator("AboutUs", getResources().getDrawable(R.drawable.aboutus)); 



     firstTabSpec.setContent(new Intent(this,HomeTab.class)); 
     secondTabSpec.setContent(new Intent(this,ContactUs.class)); 
     thirdTabSpec.setContent(new Intent(this,CallUs.class)); 
     fourthTabSpec.setContent(new Intent(this,AboutUs.class)); 




       tabhost.addTab(firstTabSpec); 
       tabhost.addTab(secondTabSpec); 
       tabhost.addTab(thirdTabSpec); 
       tabhost.addTab(fourthTabSpec);  
      } 
     }  

答えて

0

アクティビティ内のフラグメントを使用して、そのアクティビティをタブスペックに設定します。

は、LIN、次のフラグメントの使用を習得するには:http://developer.android.com/guide/topics/fundamentals/fragments.html

とfollowigチュートリアルを、タブを実装従うフラグメントを使用する方法について :

http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/

+0

私はfragments.pleseが私を提案使用する方法を知っている、DNTいくつかのアドバイスどのようにアンドロイドでフラグメントのコンセプトを使用する – user1089640

関連する問題