添加差距ExpandableListView组项目之间 [英] Add gap between group items in ExpandableListView

查看:86
本文介绍了添加差距ExpandableListView组项目之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何添加一个间隙(可以说20dp)组项目之间的 ExpandableListView ?我有一个 RelativeLayout的自定义组的布局作为父母。增加利润率家长不帮助。

How can I add a gap (lets say 20dp) between group items in ExpandableListView? I have custom group layout with RelativeLayout as a parent. Adding margins to parent doesn't help.

推荐答案

不知道你的目标的,但这里有什么想法

Not sure what you're aiming for but here's an idea

通过你在你的主要活动得到了您的自定义列表

Pass the list you got in your main activity to your custom list

MyExpandableListAdapter myAdapter = new MyExpandableListAdapter(expandableList);

在自定义列表类方法:

in your custom list class methods:

private ExpandableListView exp;

public MyExpandableListAdapter(ExpandableListView exp)
{
    this.exp = exp;
}

public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent)
{

    if (convertView == null)
    {
        LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater.inflate(R.layout.list_child, null);
    }

    exp.setDividerHeight(0);

    return convertView;

}


public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent)
{

    if (convertView == null)
    {
        LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater.inflate(R.layout.list_row, null);
    }

    exp.setDividerHeight(20);

    return convertView;
}

例如,本应群体,而不是孩子的之间添加间隔

for example, this should add spacing between groups and not the childs

这篇关于添加差距ExpandableListView组项目之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆