The fragment_line_width.xml
layout for the LineWidthDialogFragment
contains a GridLayout
that displays a GUI for selecting and previewing a new line thickness. In this section, you’ll create LineWidthDialogFragment
’s layout and the LineWidthDialogFragment
class. To add the fragment_line_width.xml
layout:
1. Expand the project’s res/layout
node in the Package Explorer.
2. Right click the layout
folder and select New > Android XML File to display the New Android XML File dialog.
3. In the dialog’s File field, enter fragment_line_width.xml
4. In the Root Element section, select GridLayout, then click Finish.
5. In the Outline window, select the GridLayout and change its Id value to @+id/ lineWidthDialogGridLayout
.
6. Using the Graphical Layout editor’s Palette, drag an ImageView and a SeekBar onto the lineWidthDialogGridLayout
node in the Outline window so that the window appears as shown in Fig. 7.9. Set each item’s Id as shown in the figure.
7. After completing Step 6, configure the GUI component properties with the values shown in Fig. 7.10, then save and close fragment_line_width.xml
.
To add class LineWidthDialogFragment
to the project:
1. Right click the package com.deitel.doodlz
in the project’s src
folder and select New > Class to display the New Java Class dialog.
2. In the Name field, enter LineWidthDialogFragment
.
3. In the Superclass field, change the superclass to android.app.DialogFragment
.
4. Click Finish to create the class.