I have problem adding children ,when i add one child then on ui two child appear with same childposition..my problem is similar to these mentioned in following questions
Child Layout is repeating many times in ExpandableListView
https://stackoverflow.com/questions/10938763/double-child-entries-in-expandablelistview
But unable to find a solution .. please see my code here
Value for children is given using this double dimension array..
String[][] child = {
mContext.getResources().getStringArray(R.array.alerts),
mContext.getResources().getStringArray(R.array.alerts),
mContext.getResources().getStringArray(R.array.alerts),
mContext.getResources().getStringArray(R.array.alerts),
mContext.getResources().getStringArray(R.array.alerts) };
I used this :
@Override
public int getChildrenCount(int groupPosition) {
return child.length;
}
but for this also child count is 5 and it shows up 10 items..
I had the exact same problem and turns out it's because I returned false in onGroupClick method in OnGroupClickListener. Here is a solution:
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int position, long id) {
// ... do stuff //
return true; // make sure you return true.
}
It seems you are hard-coded child position like,
@Override
public int getChildrenCount(int groupPosition) {
return 1;
}
where as it should be your_data_collection_size
Also, you have hard-coded childId like,
@Override
public long getChildId(int groupPosition, int childPosition) {
return 0;
}
which should be childPosition not 0
If you further have any query/problem you can download and check my demo example from you github and can come back to me with your query if you have any thereafter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With