Running on phone device


#1

I have noticed a slight bug when running the single pane version of the app. When returning to CrimeListFragment from CrimePagerActivity, the changed or new ‘Crime’ doesn’t have show the update/added title, date or solved checkbox. I was thinking that overriding onResume() and re-populating the array would fix this issue, since onResume() is only used when CrimePagerActivity ‘returns’ to CrimeListFragment. I have tried several placements of onResume(), but have not been able to get CrimeListActivity to refresh the view with the updated Array? Any ideas?


#2

What you need is a call to adapter.notifyDataSetChanged() inside CrimeListFragment.onResume(). The code for that should be somewhere in the Fragment Arguments chapter, IIRC.


#3

Thank you, that fixed it. I didn’t find a mention of “onResume()” in the chapter mentioned. I just copied “((CrimeAdapter)getListAdapter()).notifyDataSetChanged();” from the “public void updateUI()” into a new “onResuem()” Override. The final code looks like this:

@Override
public void onResume() {
	super.onResume();
	((CrimeAdapter)getListAdapter()).notifyDataSetChanged();
}

Since onResume() isn’t used in the two pane version, it doesn’t effect the way that works. (Tested and verified)


#4

Greetings,

I just checked the Chapter 22 code available for download, and indeed onResume() is not there. Are we positive this isnt an error? I only have the kindle edition, not sure if the print edition has this code.

Thanks.