アイテムが展開されたときに別のビューでカスタマイズしたい ExpandableListView があります。問題は、state_expanded 属性に割り当てた画像が表示されないことです。状態の他のほとんどすべての属性を試しましたが、何かを行うのはstate_pressedだけで、状態が押されたときに別の画像を簡単に表示します。アイテムが展開されたときに list_item_expanded ドローアブルを表示したままにするにはどうすればよいですか? アイデアや助けをいただければ幸いです。
これが私のセレクターです。
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/list_item_expanded" android:state_expanded="true"></item>
<item android:drawable="@drawable/list_item"></item>
</selector>
これが私の ExpandableListView のスタイルを設定する場所です
<style name="customExpandableList" parent="@android:style/Widget.ExpandableListView">
<item name="android:groupIndicator">@null</item>
<item name="android:dividerHeight">5dp</item>
<item name="android:divider">@android:color/transparent</item>
<item name="android:listSelector">@android:color/transparent</item>
<item name="android:cacheColorHint">@android:color/transparent</item>
<item name="android:childDivider">@android:color/transparent</item>
</style>
次のように、アダプターでセレクターをドローアブルとして設定します。
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View view, ViewGroup parent) {
if (view == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.trans_sum_row, null);
}
view.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.list_item_selector));
}