I am developing an app that use to ExpandableListview. Firstly I am adding headers and then I am adding childs to specific headers. But when I add childs , every header of ExpandableListView updating. (Screenshots explaining)
I use BaseExpandableListView adapter but not afford to solve this issue. Any help very worthy for me. Thank you
Here my Adapter Class;
public class SYCriteraAdapter extends BaseExpandableListAdapter {
private LayoutInflater inflater;
private ArrayList<SYCriteraModel> mParent;
private ArrayList<ArrayList<SYCriteraModel>> mChild;
private View view;
public ArrayList<SYCriteraModel> getMParent() {
return mParent;
}
public SYCriteraAdapter(Context context,ArrayList<SYCriteraModel> parentList) {
this.mParent = parentList;
this.inflater = LayoutInflater.from(context);
}
public SYCriteraAdapter(Context context,ArrayList<SYCriteraModel> parentList,ArrayList<ArrayList<SYCriteraModel>> childList) {
this.mParent = parentList;
this.inflater = LayoutInflater.from(context);
this.mChild = childList;
}
// counts the number of group/parent items so the list knows how many
// times calls getGroupView() method
public int getGroupCount() {
return mParent.size();
}
// counts the number of children items so the list knows how many times
// calls getChildView() method
public int getChildrenCount(int parentPosition) {
int childCount = 0;
try {
childCount = mChild.get(parentPosition).size();
}
catch (Exception e){
System.out.println("Exception " + e);
}
return childCount;
}
// gets the title of each parent/group
public Object getGroup(int i) {
return null;
}
// gets the name of each item
public Object getChild(int parentPosition, int childPosition) {
return null;
}
public long getGroupId(int parentPosition) {
return 0;
}
public long getChildId(int i, int childPosition) {
return 0;
}
public boolean hasStableIds() {
return false;
}
// in this method you must set the text to see the parent/group on the list
public View getGroupView(int parentPosition, boolean b, View view, ViewGroup viewGroup) {
if (view == null) {
view = inflater.inflate(R.layout.critera_upper_adapter, viewGroup, false);
}
TextView uppercritera = (TextView) view.findViewById(R.id.etCritera);
this.notifyDataSetChanged();
uppercritera.setText(mParent.get(parentPosition).getParent());
return view;
}
// in this method you must set the text to see the children on the list
public View getChildView(int parentPosition, int childPosition, boolean b, View view, ViewGroup viewGroup) {
if (view == null) {
view = inflater.inflate(R.layout.critera_lower_adapter, viewGroup, false);
}
TextView lowerCritera = (TextView) view.findViewById(R.id.etCritera);
lowerCritera.setText(mChild.get(parentPosition).get(childPosition).getChildren());
return view;
}
public boolean isChildSelectable(int i, int i1) {
return true;
}
}