我也是同一類型的問題,但我一直在使用給定的代碼
tabHost = getTabHost(); // The activity TabHost
tabHost.setOnTabChangedListener(this);
Resources res = getResources(); // Resource object to get Drawables
tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Reusable TabSpec for each tab
TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
TabSpec secondTabSpec = tabHost.newTabSpec("tid2");
TabSpec thirdTabSpec = tabHost.newTabSpec("tid3");
TabSpec fourthTabSpec = tabHost.newTabSpec("tid4");
TabSpec fifthTabSpec = tabHost.newTabSpec("tid5");
viewCache[0] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
viewCache[1] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
viewCache[2] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
viewCache[3] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
viewCache[4] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
firstTabSpec.setIndicator(viewCache[0]);
secondTabSpec.setIndicator(viewCache[1]);
thirdTabSpec.setIndicator(viewCache[2]);
fourthTabSpec.setIndicator(viewCache[3]);
fifthTabSpec.setIndicator(viewCache[4]);
firstTabSpec.setContent(new Intent(this, HomeTabActivityGroup.class));
secondTabSpec
.setContent(new Intent(this, ProfileTabActivityGroup.class));
thirdTabSpec.setContent(new Intent(this,
NotificationTabActivityGroup.class));
fourthTabSpec.setContent(new Intent(this,
FavoritesTabActivityGroup.class));
fifthTabSpec
.setContent(new Intent(this, MoreTabActivityGroupNew.class));
tabHost.addTab(firstTabSpec);
tabHost.addTab(secondTabSpec);
tabHost.addTab(thirdTabSpec);
tabHost.addTab(fourthTabSpec);
tabHost.addTab(fifthTabSpec);
currentTabvalue = tabHost.getCurrentTab();
C2DMessaging.register(TennisAppActivity.mContext,
"[email protected]");
for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
// tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#7392B5"));
switch (i) {
case 0:
tabHost.getTabWidget().getChildAt(i)
.setBackgroundResource(R.drawable.home);
break;
case 1:
tabHost.getTabWidget().getChildAt(i)
.setBackgroundResource(R.drawable.profile);
break;
case 2:
tabHost.getTabWidget().getChildAt(i)
.setBackgroundResource(R.drawable.notifications);
break;
case 3:
tabHost.getTabWidget().getChildAt(i)
.setBackgroundResource(R.drawable.fav);
break;
case 4:
tabHost.getTabWidget().getChildAt(i)
.setBackgroundResource(R.drawable.more);
break;
}
}
// * ** 休耕打擊刪除它* ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * *** ** * ** * ** 這是使用它的xml文件。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center">
<ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="50dip"></ImageView>
我希望這是幫助全給你。
我認爲這是接頭主機的背摔,如何在標籤的工作..你可以將其設置爲空或透明或白色甚至 – Mutmatt
怎麼說也done..can請你告訴它# – AndroidDev
'MyTabHost.setBackgroundColor(#000000);'我會建議作爲一個答案,但我不是100%肯定...只是猜測我如何理解tabhosts和標籤工作從過去的exp。 – Mutmatt