[英]How to make a bottom tab bar in android?
我正在使用此代碼將底部的標簽欄放置在android中,但未出現在應用程序的布局頁面中。 另外,我在drawable中制作了maintab.xml和其他選項卡所需的文件。 但仍然無法正常工作。 你能告訴我出什么問題了嗎?
public class TabbottonActivity extends TabActivity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maintab);
setTabs() ;
}
private void setTabs()
{
addTab("Home", R.drawable.tab_home, MenuActivity.class);
addTab("Search", R.drawable.tab_search, DestinationActivity.class);
addTab("Home", R.drawable.tab_home, MenuActivity.class);
addTab("Search", R.drawable.tab_search, DestinationActivity.class);
}
private void addTab(String labelId, int drawableId, Class<?> c)
{
TabHost tabHost = getTabHost();
Intent intent = new Intent(this, c);
TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);
View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
TextView title = (TextView) tabIndicator.findViewById(R.id.title);
title.setText(labelId);
ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
icon.setImageResource(drawableId);
spec.setIndicator(tabIndicator);
spec.setContent(intent);
tabHost.addTab(spec);
}
}
不要使用底部標簽欄
不要使用底部的標簽欄Tther平台使用底部的標簽欄在應用程序視圖之間切換。 根據平台慣例,Android的視圖控制選項卡顯示在屏幕頂部的操作欄中。 此外,Android應用程序可能會使用底部的條在拆分操作條上顯示操作。
您應遵循此准則,以與Android平台上的其他應用程序創建一致的體驗,並避免操作之間的混淆以及在Android上的視圖切換。
來自: http : //developer.android.com/design/patterns/pure-android.html
編輯:應該如何創建選項卡
http://developer.android.com/training/implementing-navigation/lateral.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.