tabhost 不显示 tab标签内容 android,TabHost 4.2图标和不显示在标签上的颜色_android-tabhost_开发99编程知识库...

我們對Android開發非常新,所以如果這是很明顯的。

我們正在使用選項卡式視圖實現 Activity 。 我們所擁有的問題是標籤上的圖標和適當的顏色本身沒有正確顯示在 Jelly Bean ( 安卓 4.2 ) 上。 但是,它們在早期的API級別上可以正確顯示,比如 Gingerbread 。

請注意:我們最初使用過時的TabActivity類創建了視圖。 然而,就我所知道的,這樣做的"較新"方法不應該與舊的方法不同。 如果我錯了,請糾正我。

這是包含選項卡主機布局的xml:<?xml version="1.0" encoding="utf-8"?>

android:id="@android:id/tabhost"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@color/Black">

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:padding="5dp">

android:id="@android:id/tabs"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_weight="0"/>

android:id="@android:id/tabcontent"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_weight="1">

下面是相關的( 我希望) Activity 代碼:public class MainTabActivity extends FragmentActivity implements TabHost.TabContentFactory

private TabHost tabHost;

//other instance variables.. .

@Override

public void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);

tabHost = (TabHost)findViewById(android.R.id.tabhost);

tabHost.setup();

TabSpec loginTabSpec = tabHost.newTabSpec(GlobalConstants.LOGIN_ACTIVITY);

loginTabSpec.setIndicator("Settings", getResources().getDrawable(R.drawable.ic_action_settings_gear));

loginTabSpec.setContent(this);

TabSpec mainTabSpec = tabHost.newTabSpec(GlobalConstants.MAIN_ACTIVITY);

mainTabSpec.setIndicator("Lone Worker", getResources().getDrawable(R.drawable.ic_action_settings_phone));

mainTabSpec.setContent(this);

tabHost.addTab(mainTabSpec);

tabHost.addTab(loginTabSpec);

}

這就是 Jelly Bean ( 錯誤版本) 上標籤本身的樣子:

img.php?siteid=1&aid=2520671&hash=d1pKTTIucG5n

最後,這是它應該看起來像( 在 Gingerbread 上。 好版本):

img.php?siteid=1&aid=2520671&hash=bmVVTGEuanBn

因這裡,選項卡的背景顏色是黑色( 當它正常的藍色顏色),但是很難從錯誤的屏幕快照中出現。 我希望這個問題在這裡得到了。 請告訴我是否有遺漏。 感謝你提前致謝 !

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值