Body
The first is the most basic
Expandablelistview Vlist = (expandablelistview) This.findviewbyid (r.id.list);
Elistadapter adapter = new Elistadapter (Getapplicationcontext (), list); List is the data source
Vlist.setadapter (adapter);
The adapter does not write, all understand the
class Elistadapter extends Baseexpandablelistadapter {}
In general, ListView is updated with the notifydatasetchanged ()
Adapter.notifydatasetchanged ();
Expandablelistview is also ListView, it is estimated that this is possible.
Unfortunately, it's not ListView, it's expandablelistview!. So the error is 0. 0
Java.lang.ClassCastException:Android.widget.ExpandableListConnector
Looking for information in Google, found that many of them make this mistake. The solution is also quite simple!
Class Elistadapter extends Baseexpandablelistadapter {public
elistadapter (context, list<t> List) { c2/>this.list = list;
This.context = context;
Handler = new Handler () {
@Override public
void Handlemessage (msg) {
notifydatasetchanged ();
Super.handlemessage (msg);}}
;
public void Refresh () {handler.sendmessage () (
New Message ());
}
We can use notifydatasetchanged () as long as we call the Refresh () method.
But!! Only Groupview update!!
Childview not updated! Oh, my gosh. To be updated in the childview!!
Continue to rely on Google Niang! We all provide a lot of methods, there is a person said, directly in the list add item to be updated on it!
I tried it, no effect ...
Check the SDK documentation and find that group scaling can cause getchildview (int, int, boolean, View, ViewGroup) to run!
So the method of refreshing the Childview is very simple.
It's only a stretch once! Even adapter don't have to rewrite! Easy, huh?
Vlist.collapsegroup (groupposition);
Vlist.expandgroup (groupposition);
The above is a small series for everyone to bring Android on the Expandablelistview refresh problem solution to all the content, I hope that we support cloud Habitat Community ~