O'Reilly logo

Android Programming: The Big Nerd Ranch Guide by Brian Hardy, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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)

p​u​b​l​i​c​ ​c​l​a​s​s​ ​R​u​n​F​r​a​g​m​e​n​t​ ​e​x​t​e​n​d​s​ ​F​r​a​g​m​e​n​t​ ​{​
 ​ ​ ​ ​p​r​i​v​a​t​e​ ​s​t​a​t​i​c​ ​f​i​n​a​l​ ​S​t​r​i​n​g​ ​T​A​G​ ​=​ ​"​R​u​n​F​r​a​g​m​e​n​t​"​;​
 ​ ​ ​ ​p​r​i​v​a​t​e​ ​s​t​a​t​i​c​ ​f​i​n​a​l​ ​S​t​r​i​n​g​ ​A​R​G​_​R​U​N​_​I​D​ ​=​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required