Coding TitlesFragment
We are really close to being able to actually show a photo in our Photos app. We need to load a list of photo titles from our database into ListView, provided by ListFragment, and handle what happens when the user clicks on a list item.
Some of the code in here won't make complete sense until we finish coding MainActivity, which will, of course, handle the communication between TitlesFragment and ViewFragment, as well as TagsFragment and TitlesFragment.
Let's add two new members to TitlesFragment—a Cursor member to load some data into and an instance of our new interface.
Add the two highlighted member variables where shown:
public class TitlesFragment extends ListFragment {
private Cursor mCursor;
private ActivityComs mActivityComs;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}Next, in the onCreate method, we do the following:
- Get a string to represent the tag from
Bundle, usinggetArguments...