[英]I want to remove the groupView of an ExpandableListView when there is no childView in it
Forgive me on my question way and my English . 请原谅我的提问方式和我的英语。 I want to remove the groupView of my ExpandableListView when there is no childView for it .I get my Expandedable childView through using retrofit 2 .
我想在没有childView的情况下删除我的ExpandableListView的 groupView 。我通过使用翻新2获得我的Expandedable childView 。 Please be patient with me because I have a little skills in developing android :)
请耐心等待,因为我在开发android方面有一点技巧:)
Here is my ExpandableListView Adapter code 这是我的ExpandableListView适配器代码
public class ExpandableListAdapter extends BaseExpandableListAdapter {
private Context _context;
private List<Headers> _listDataHeader;
private HashMap<Headers, List<FixturesObject>> _listDataChild;
public ExpandableListAdapter(Context context, List<Headers> listDataHeader,
HashMap<Headers, List<FixturesObject>> listChildData) {
this._context = context;
this._listDataHeader = listDataHeader;
this._listDataChild = listChildData;
}
@Override
public int getGroupCount() {
return this._listDataHeader.size();
}
@Override
public int getChildrenCount(int groupPosition) {
return this._listDataChild.get(this._listDataHeader.get(groupPosition))
.size();
}
@Override
public Object getGroup(int groupPosition) {
return this._listDataHeader.get(groupPosition);
}
@Override
public Object getChild(int groupPosition, int childPosition) {
return this._listDataChild.get(this._listDataHeader.get(groupPosition))
.get(childPosition);
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
Headers headers = (Headers) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_group, null);
}
TextView lblListHeader = (TextView) convertView.findViewById(R.id.textHeader);
lblListHeader.setTypeface(null, Typeface.BOLD);
ImageView imageView = (ImageView) convertView.findViewById(R.id.image);
lblListHeader.setText(headers.getNameLeague());
imageView.setImageResource(headers.getImageID());
return convertView;
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
FixturesObject fixturesObject =(FixturesObject) getChild(groupPosition,childPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_item, null);
}
TextView HomeTeamName = (TextView) convertView.findViewById(R.id.home_team_name);
HomeTeamName.setText(fixturesObject.getMatchHometeamName());
return convertView;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
一种方法是编辑getGroupView
以在getChildrenCount( groupPosition ) == 0
返回高度为0dp的空FrameLayout,并在有子代的情况下使用当前代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.