有可能在扩展群组时更改群组内的图像视图吗?
我正在寻找通过代码实现此目的的方法。
欢呼任何提示
编辑:这是我目前正在尝试使用的,但它不会交换图像
private static final int[] EMPTY_STATE_SET = {};
private static final int[] GROUP_EXPANDED_STATE_SET = {android.R.attr.state_expanded};
private static final int [] [] GROUP_STATE_SETS = {
EMPTY_STATE_SET, //0
GROUP_EXPANDED_STATE_SET //1
};
public View getGroupView (int groupPosition,
boolean isExpanded,
View convertView,
ViewGroup parent) {
View v = getGroupView( groupPosition, isExpanded, convertView, parent);
View ind = v.findViewById(R.id.explist_indicator);
if(ind != null){
ImageView indicator = (ImageView) ind;
indicator.setVisibility( View.VISIBLE );
int stateSetIndex = ( isExpanded ? 1:0);
Drawable drawable = indicator.getDrawable();
drawable.setState(GROUP_STATE_SETS[stateSetIndex]);
}
return v;
}
答案 0 :(得分:0)
使用自定义BaseExpandableListAdapter
。覆盖getGroupView
并使用isExpanded
布尔参数来识别组视图的展开时间(并相应地设置ImageView
)。