From the file CrimeListFragment:

[code]public class CrimeListFragment extends ListFragment {
private ArrayList mCrimes;
private static final String TAG = “CrimeListFragment”;

public void onCreate(Bundle savedInstanceState) {
	mCrimes = CrimeLab.get(getActivity()).getCrimes();
	CrimeAdapter adapter = new CrimeAdapter(mCrimes);

I am a little confused about the getActivity() method in the line, getActivity().setTitle(R.string.crimes_title). I assume that it is setting the title of the Activity to “Crimes”, is that correct? What class is this method defined in? I have been having trouble finding the documentation for it. Can someone please explain this a little further and where the docs are?

And I am also confused about the line mCrimes = CrimeLab.get(getActivity()).getCrimes(). Can’t someone help here as well?

Thanks in advance.


Can anyone help with this?




getActivity is a convenience method for the Fragment class and returns the Activity that the Fragment is currently associated with.

Here’s a link to the API doc for the Fragment class: Fragment Class API Doc