ExpandableListView箭头右边显示方法

来源:互联网 发布:私有密码算法范畴 编辑:程序博客网 时间:2024/04/30 05:53

1首先 ExpandableListView elistview;

         elistview.setGroupIndicator(null);//将控件默认的左边箭头去掉,

2在 自定义的继承自BaseExpandableListAdapter的adapter中有一个方法

/**
 * 父类view
 */
    @Override
    public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {
        Log.i("zhaoxiong","parent view");
            LinearLayout parentLayout=(LinearLayout) View.inflate(context, R.layout.wowocoupons_parent_item, null);
            TextView parentTextView=(TextView) parentLayout.findViewById(R.id.parentitem);
            parentTextView.setText(parentlist.get(groupPosition));
            ImageView parentImageViw=(ImageView) parentLayout.findViewById(R.id.arrow);

//判断isExpanded就可以控制是按下还是关闭,同时更换图片
            if(isExpanded){
                parentImageViw.setBackgroundResource(R.drawable.arrow_down);
            }else{
                parentImageViw.setBackgroundResource(R.drawable.arrow_up);
            }

       
        return parentLayout;
    }

0 0