2

2.3에서 탭 아이콘을 변경하려고 할 때 작동하지만 Android 4.1.2에서는 작동하지 않습니다.android 4.1.2에서 캔트 변경 탭 아이콘

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

기기 3.0 이하를 사용할 때 ic_launcher 아이콘이 표시됩니다.

답변

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>