Skip to content Skip to sidebar Skip to footer

Notifydatasetchanged() Fails To Update Adapter Onclick

I'm following this tutorial on ExpandableListViews. I want my implementation to show a new value added after tapping a button. However, nothing I have tried works. In addition to p

Solution 1:

This method doesn't work for me also (and I'm not sure why. My guess is that it will only work with Contnet providers). Instead of using notifyDataSetChanged() you can just requery/add new data to your groups and reset the adapter.

adapter =new MyExpandableListAdapter(getActivity(), groups);
listView.setAdapter(adapter);

Solution 2:

your if statement is probably never called:

if (termSelection.toString() == "Fall 2013")

should be

if (termSelection.toString().equals("Fall 2013"))

EDIT:

== checks for object identity, when using Strings. you most probably mean equals instead.

Also i'd advise you to get familiar with the debugger and/or LogCat/Log.d(), this will save you tons of trouble;

Solution 3:

You can try setting list adapter again:

listView.setAdapter(adapter);

Solution 4:

Try surrounding your notifysetchange with runOnUIThread(new Runnable(...)). Since you make a change with your listView it should be updated within your UI thread. Also a good way if you are not familiar with the breakpoints, try logging with your if statements and see if your conditions are set true.

Post a Comment for "Notifydatasetchanged() Fails To Update Adapter Onclick"