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)

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

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="http://schemas.android.com/apk/res/android"
              ... >
    ...
    <CheckBox
            android:id="@+id/crime_solved"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/crime_solved_label"/>

    <Button
            android:id="@+id/crime_suspect"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/crime_suspect_text"/>

    <Button
            android:id="@+id/crime_report"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/crime_report_text"/>
</LinearLayout>

Preview the updated layout or run CriminalIntent to confirm that your new buttons are in place.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.88.130