Working with Existing Runs

The next logical thing to do is allow the user to navigate from the list of runs to the details of a specific run. In order for this to work well, RunFragment needs some support for passing a run ID as an argument. Since you host RunFragment in RunActivity, it too needs an extra for the run ID.

First, add the argument to RunFragment and a newInstance(long) method to make it easier to use.

Listing 34.18  Adding a run ID argument (RunFragment.java)

public class RunFragment extends Fragment {
    private static final String TAG = "RunFragment";
    private static final String ARG_RUN_ID = "RUN_ID";

    ...

    private TextView mStartedTextView, mLatitudeTextView,
        mLongitudeTextView, mAltitudeTextView, mDurationTextView;

 public static RunFragment ...

Get Android Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.