无法更改android 4.1.2上的选项卡图标

无法更改android 4.1.2上的选项卡图标,android,android-fragments,android-tabhost,android-tablelayout,android-drawable,Android,Android Fragments,Android Tabhost,Android Tablelayout,Android Drawable,当我尝试在2.3中更改选项卡图标时,它可以工作,但在安卓4.1.2上无法工作 mTabHost.addTab(mTabHost.newTabSpec("device").setIndicator("Device", getResources().getDrawable(R.drawable.ic_launcher)), FragmentOne.class, null); 在设备3.0或更低版本上使用时,我可以看到

当我尝试在2.3中更改选项卡图标时,它可以工作,但在安卓4.1.2上无法工作

 mTabHost.addTab(mTabHost.newTabSpec("device").setIndicator("Device",
                    getResources().getDrawable(R.drawable.ic_launcher)),
                    FragmentOne.class, null);
在设备3.0或更低版本上使用时,我可以看到ic_启动器图标。

使用片段

为了支持所有版本,最好使用Action bar sherlock库并实现它


刚刚在我的选项卡中增加了自定义布局,解决了我的问题-

TabSpec tSpecWork = mTabHost.newTabSpec("work");
        View tabIndicator   = LayoutInflater.from(this).inflate(R.layout.tabimage,mTabHost.getTabWidget(),false);
        ((TextView) tabIndicator.findViewById(R.id.title_tab)).setText(getString(R.string.message)); 
        ((ImageView) tabIndicator.findViewById(R.id.icon_tab)).setImageResource(R.drawable.ic_launcher);

        tSpecWork.setIndicator(tabIndicator);    

        mTabHost.addTab(tSpecWork,
                FragmentOne.class, null);
这是我的tabimage xml文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  android:orientation="vertical"
  android:layout_weight="1"
  android:padding="5dp" >

 <ImageView
      android:id="@+id/icon_tab"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
 />

  <TextView
      android:id="@+id/title_tab"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textColor="#000000" />
</LinearLayout>