Adding Buttons

Update CrimeFragment’s layout to include new buttons for accusation and tattling: namely, a suspect button and a report button. First, add the strings that these buttons will display.

Listing 15.1  Adding button strings (res/values/strings.xml)

    <string name="new_crime">New Crime</string>
    <string name="crime_suspect_text">Choose Suspect</string>
    <string name="crime_report_text">Send Crime Report</string>

In res/layout/fragment_crime.xml, add two button widgets, as shown in Listing 15.2.

Listing 15.2  Adding CHOOSE SUSPECT and SEND CRIME REPORT buttons (res/layout/fragment_crime.xml)

<LinearLayout xmlns:android="" ... > ... <CheckBox android:id="@+id/crime_solved" ...

Get Android Programming: The Big Nerd Ranch Guide, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.