Actions we take on POIDetailActivity
, such as Save
and Delete
, have an effect on the data that would have been previously displayed on POIListActivity
; we need to be sure that ListView
on POIListActivity
is refreshed when it becomes active again. BaseAdapter<>
provides a method NotifyDataSetChanged()
, which can be used to cause an adapter to refresh or repopulate an adapter View. The best place to call NotifyDataSetChange()
would be in the OnResume()
method. As you may recall from Chapter 1, The Anatomy of an Android App, when an activity is moved to the background due to the start of a new activity, the OnPause()
method is called. This would have happened for POIListActivity
when POIDetailActivity
was started. When POIDetailActivity
is completed, POIListActivity
will be brought back to the foreground and the OnResume()
method will be called. The following listing shows what is needed to refresh POIListActivity
:
protected override void OnResume (){ base.OnResume (); _adapter.NotifyDataSetChanged (); }
18.118.200.86