2

2.3 でタブ アイコンを変更しようとすると、機能しますが、Android 4.1.2 では機能しません。

 mTabHost.addTab(mTabHost.newTabSpec("device").setIndicator("Device",
                    getResources().getDrawable(R.drawable.ic_launcher)),
                    FragmentOne.class, null);

3.0 以下のデバイスで使用すると、ic_launcher アイコンが表示されます。

4

2 に答える 2

1

タブでカスタムレイアウトを膨らませただけで問題が解決しました-

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>
于 2013-06-07T12:56:27.937 に答える