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

Creating a UI Fragment

The steps to creating a UI fragment are the same as those you followed to create an activity:

  • compose an interface by defining widgets in a layout file

  • create the class and set its view to be the layout that you defined

  • wire up the widgets inflated from the layout in code

Defining CrimeFragment’s layout

CrimeFragment’s view will display the information contained within an instance of Crime. Eventually, the Crime class and CrimeFragment’s view will include many interesting pieces, but for this chapter, you just need a text field to contain the crime’s title.

Figure 7.14 shows the layout for CrimeFragment’s view. It consists of a vertical LinearLayout that contains an EditText. EditText is a widget that presents an area where ...

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