2.5.2. Changing the Id Property of the RelativeLayout and the TextView

When a GUI is displayed in the Graphical Layout editor, you can use the Properties window at the bottom of the Outline window to configure the selected layout’s or component’s properties without editing the XML directly. To select a layout or component, either click it in the Graphical Layout editor or select its node in the Outline window (Fig. 2.14).

Image

Fig. 2.14 | Hierarchical GUI view in the Outline window.

You should rename each layout and component with a relevant name, especially if the layout or component will be manipulated programmatically (as we’ll do in later apps). Each object’s name is specified via its Id property. You can use the Id to access and modify a component without knowing its exact location in the XML. As you’ll see shortly, the Id can also be used to specify the relative positioning of components in a RelativeLayout.

Select the RelativeLayout, then at the top of the Properties window set its value to

@+id/welcomeRelativeLayout

The + in the syntax @+id indicates that a new id (that is, a variable name) should be created with the identifier to the right of the forward slash (/). Next, select the TextView and set its Id property to

@+id/welcomeTextView

The Properties window should now appear as in Fig. 2.15.

Image

Fig. 2.15 | Properties window after changing the Id properties of the RelativeLayout and TextView in the app’s default GUI.

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

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