2011-04-26 39 views
0

我正在使用TabHost活動進行應用程序。我在這個插入到TabHost視圖的4類中有5個不同的類。在一個特定的類中,我有列表視圖與onItemclicklistener。同時點擊列表視圖,它會轉到不同的活動(即第5課)。我想將點擊的活動放在TabHost中。 (即)每當我單擊列表視圖,調用活動應該出現在TabHost.But現在它沒有標籤主機。我想通過點擊列表視圖在第5課中放置Tab主機。我不知道如何做到這一點,如果有任何人有想法請告訴我,並指導我如何做到這一點。如何獲得TabHost

回答

2
host= (TabHost)findViewById(android.R.id.tabhost); 
     host.setup(); 


     TabHost.TabSpec spec; 

     // Create an Intent to launch the first Activity for the tab (to be reused) 
     Intent i = new Intent().setClass(this, library.class); 

     spec = host.newTabSpec ("FirstGroup").setIndicator("Library",getResources().getDrawable(R.drawable.imagename)).setContent(i); 

     host.addTab(spec); 

u必須添加所有的活動是這樣的(這裏庫)