android - How to notifydatasetchanged between two activities -
i have 2 activities each contain fragments. activity has fragment listview. rows of listview obtained sqlitedatabase.
activity b contains fragment enables entries of database edited. when user edits database entry, saves data, returns activity via backbutton or:
actionbar = getsupportactionbar(); actionbar.setdisplayhomeasupenabled(true); actionbar.sethomebuttonenabled(true);
how notify listview in activity there has been change database? understand how communicate between activity , it's fragments, how implement notifydatasetchanged when fragments in 2 different activities?
i suspect going activity via button recalling view stack, view has changed when there database change.
you call notifydatasetchanged
in onresume
in activity a. when close or go activity b a, update data. don't forget check if adapter different null, otherwise crash first time open app.
you make public function in activity updates list , call activity b.
class activitya public static void updatelist() { if(adapter != null){ adapter.notifydatasetchanged; } } class activityb activitya.updatelist();
hope helps :)
Comments
Post a Comment