March 2013
Beginner to intermediate
580 pages
16h 11m
English
Now that your layouts are behaving properly, you can turn to adding a CrimeFragment to the detail fragment container when CrimeListActivity is sporting a two-pane layout.
You might think to simply write an alternative implementation of CrimeListFragment.onListItemClick(…) for tablets. Instead of starting a new CrimePagerActivity, onListItemClick(…) would get CrimeListActivity’s FragmentManager and commit a fragment transaction that adds a CrimeFragment to the detail fragment container.
The code would look like this:
public void onListItemClick(ListView l, View v, int position, long id) { // Get the Crime from the adapter Crime crime = ((CrimeAdapter)getListAdapter()).getItem(position); // Stick a new CrimeFragment in ...Read now
Unlock full access