圆角ExpandableListView

时间:2018-09-17 13:38:08

标签: android android-layout expandablelistview

嗨,我正在创建一个ExpandableListView,当它未展开时,应该具有用于​​组项目的圆角卡。圆角卡必须扩展为组的背景,并且是子组。附加图像。应该怎么做。

谢谢

enter image description here

1 个答案:

答案 0 :(得分:0)

如果您的适配器是extends BaseExpandableListAdapter,请尝试:

@Override
public View getGroupView(int groupPosition, boolean isExpanded, View view, ViewGroup viewGroup) {
    LayoutInflater inflater = LayoutInflater.from(context);
    if(isExpanded){
        view = inflater.inflate(R.layout.two_up_round_corners_group, null);
    }else{
        view = inflater.inflate(R.layout.four_round_corners_group, null);
    }
    // Populate your view here.

    return view;
}

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLast, View view, ViewGroup viewGroup) {
    LayoutInflater inflater = LayoutInflater.from(context);
    if(isLast){
        view = inflater.inflate(R.layout.two_bottom_round_corners_child, null);
    }else{
        view = inflater.inflate(R.layout.normal_child, null);
    }
    // Populate your view here.

    return view;
}

请相应地进行布局。希望有帮助!