Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)

(gtxtreme123) #1
Building the Scene

Now turn SunsetActivity into a SingleFragmentActivity that displays your fragment.


Listing 32.5  Displaying SunsetFragment (SunsetActivity.java)


public class SunsetActivity extends SingleFragmentActivity {


@Override
protected Fragment createFragment() {
return SunsetFragment.newInstance();
}


@Override
protected void onCreate(Bundle savedInstanceState) {
...
}
}


Take a moment to run Sunset to make sure everything is hooked up correctly before moving on. It
should look like Figure 32.1. Ahhh.


Figure 32.1  Before sunset

Free download pdf