アクティビティの1つでタブビューを使用しています。タブの選択に基づいて、タブのドローアブルを変更したいと思います。つまり、このようになります。T11、T12、T21、T22の4つの画像があります。最初にタブ1を選択した状態で画像T11とT22を設定したいと思います。タブ2を選択したらすぐに、画像をT12とT21に変更したいと思います。
これまでのところ、ドローアブルタイプのxmlファイルを使用して使用してみました。
左タブ用に描画可能(tab1)-
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
style="?attr/left_active" />
<item android:state_window_focused="false" android:state_enabled="false"
style="?attr/left_inactive" />
<item android:state_pressed="true" android:state_enabled="true"
style="?attr/left_active" />
<item android:state_pressed="true" android:state_enabled="false"
style="?attr/left_inactive" />
</selector>
タブ右(Tab2)の描画可能-
<item android:state_window_focused="false" android:state_enabled="true"
style="?attr/right_active" />
<item android:state_window_focused="false" android:state_enabled="false"
style="?attr/right_inactive" />
<item android:state_pressed="true" android:state_enabled="true"
style="?attr/right_active" />
<item android:state_pressed="true" android:state_enabled="false"
style="?attr/right_inactive" />
活動中:
TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("Tab1", getResources().getDrawable(R.drawable.left)).setContent(new Intent(this, Left.class)));
tabHost.addTab(tabHost.newTabSpec("tab2")
.setIndicator("Tab2", getResources().getDrawable(R.drawable.right))
.setContent(new Intent(this, Right.class)));
tabHost.setCurrentTab(1);
助けてください...