由於每個選項卡都處於活動狀態,因此該活動可以具有其自己的XML佈局。
public class ArtistsActivity1 extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
}
}
public class ArtistsActivity2 extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
}
}
intent1 = new Intent().setClass(this, ArtistsActivity1.class);
spec = tabHost.newTabSpec("artists").setIndicator("Artists",
res.getDrawable(R.drawable.ic_tab_artists))
.setContent(intent1);
tabHost.addTab(spec);
intent2 = new Intent().setClass(this, AlbumsActivity2.class);
spec = tabHost.newTabSpec("albums").setIndicator("Albums",
res.getDrawable(R.drawable.ic_tab_albums))
.setContent(intent2);
tabHost.addTab(spec)
so main1.xml和main2.xml將設置相同的標籤,並且不同的佈局在之內? –
user1109893
2011-12-21 22:40:06