0

展开时如何为 ExpandedListview 的子项设置不同的背景图像/形状可绘制?

4

1 回答 1

0

检查自定义适配器的 getChildView 方法。根据条件,正确设置子视图的背景。检查一下:

@Override
        public View getChildView(int groupPosition, int childPosition,
                boolean isLastChild, View convertView, ViewGroup parent) {
            View childView = getLayoutInflater().inflate(R.layout.item, null);
            if(groupPosition == 0){
                childView.setBackgroundResource(R.id.background_a);
            }else{
                childView.setBackgroundResource(R.id.background_b);
            }
            return childView;
        }
于 2013-10-29T07:31:09.957 回答