Yur*_*yak 2 android android-layout
如何在组项目之间添加间隙(比方说20dp)ExpandableListView?我有自定义组布局RelativeLayout作为父级.向父母添加边距并没有帮助.
不确定你的目标是什么,但这是一个想法
将您在主活动中获得的列表传递到自定义列表
MyExpandableListAdapter myAdapter = new MyExpandableListAdapter(expandableList);
Run Code Online (Sandbox Code Playgroud)
在自定义列表类方法中:
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;
}
Run Code Online (Sandbox Code Playgroud)
例如,这应该在组之间添加间距而不是孩子
| 归档时间: |
|
| 查看次数: |
4386 次 |
| 最近记录: |