I'd like to disable expandability for some items in the ExpandableListView.
So far I know it can be done form ExpandableListView but I think it's not good to control what to show/why/where NOT from ListView - this task belongs to adapter and there I want to disable expandability.
So how to do it from a class which extends BaseExpandableListAdapter?
So far I've tried to set convertView
visibility to View.GONE
but it does not work (i.e. it shows some weird View, empty but not View.GONE
)
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
if (null == convertView) {
convertView = inflater.inflate(R.layout.system_status_child, parent, false);
}
Item item = systemStatus.get(groupPosition);
if(item.isStatusOk()){
convertView.setVisibility(View.GONE);
}
else{
convertView.setVisibility(View.VISIBLE);
((TextViewMuseo)convertView).setText(item.getChild_text());
}
return convertView;
}
system_status_child.xml
looks like this:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/system_status_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="some text" />
Just return 0 as the children count for those groups: