Solution to the refresh problem of expandablelistview in Android
text
The first is the most basic
In general, the listview is updated using notifydatasetchanged()
adapter.notifyDataSetChanged();
Expandablelistview is also a listview. It is estimated that this is OK. Unfortunately, it is not a listview but an expandablelistview! So it reported an error of 0.0
Java.lang.ClassCastException: Android.widget.ExpandableListConnector
I found information in Google and found that many people made this mistake. The solution is also quite simple!
As long as we call the refresh () method, we can use notifydatasetchanged ()
But!! Only groupview updates!!
Childview has not been updated! Terrible... The one to be updated is in childview!!
Continue to rely on Google mother! We all provide many methods. One person said that it's OK to add items directly to the list and then update them!
I tried it and it didn't work
After checking the SDK documentation, it is found that the expansion of the group will cause getchildview (int, int, Boolean, view, ViewGroup) to run!
Therefore, the method of refreshing childview is very simple
Only stretch once! You don't even have to rewrite the adapter! Is it easy?
The above is all about the Android solution to the expandablelistview refresh problem brought by Xiaobian. I hope you can support more programming tips~