0
我想要做一個簡單的標籤應用程序在Android與四個選項卡選項卡。我的問題是,當我要顯示的圖標和指標,它只是只顯示文本的指標,我希望顯示tabhost繪製和指示燈的文字,這是我的代碼:android:無法顯示指標文本和tabhost上繪製
@Override
protected void onCreate(Bundle savedInstanceState) {
//hide title bar
BasicDisplaySettings.toggleTaskBar(SimasCardMainActivity.this, false);
//show status bar
BasicDisplaySettings.toggleStatusBar(SimasCardMainActivity.this, true);
super.onCreate(savedInstanceState);
setContentView(R.layout.simascard);
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, TerbaruSimasCard.class);
spec = tabHost.newTabSpec("Terbaru").setIndicator("Terbaru",
res.getDrawable(R.drawable.menu_terbaru))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, MerchantSimasCard.class);
spec = tabHost.newTabSpec("Merchant").setIndicator("Merchant",
res.getDrawable(R.drawable.menu_merchant))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, TentangSimasCard.class);
spec = tabHost.newTabSpec("Tentang").setIndicator("Tentang",
res.getDrawable(R.drawable.menu_tentang))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, FaqSimasCard.class);
spec = tabHost.newTabSpec("FAQ").setIndicator("FAQ",
res.getDrawable(R.drawable.menu_faq))
.setContent(intent);
tabHost.addTab(spec);
for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++){
tabHost.getTabWidget().getChildAt(i).setPadding(0,0,0,0);
tabHost.getTabWidget().getChildTabViewAt(i).setBackgroundDrawable(null);
}
tabHost.setCurrentTab(0);
}
// @Override
public void onBackPressed() {
finish();
}
當我使用
spec = tabHost.newTabSpec("Tentang").setIndicator("",
res.getDrawable(R.drawable.menu_tentang))
.setContent(intent);
它會顯示一個圖標,但當我在setIndicator
如setIndicator("Tentang")
上添加文本時,它只顯示tabhost上的指示符文本,我不知道我的代碼出了什麼問題,我試圖獲得增加標籤高度,但它不起作用,我希望有人能幫我解決我的問題。謝謝
嚴重?我不認爲它會起作用.... –
@AoyamaNanami看我的編輯 –