A (175)

(Tuis.) #1
CHAPTER 7: Making Apps Interactive: Intents, Event Handling, and Menus 235

Using Buttons in UI Designs: The Button Widget


Add a new line underneath your child tag, and use the left chevron < character to again
bring up the UI widget helper dialog. Find the Button widget class, as is shown in Figure 7-17,
and select, and double-click on, the Button widget in order to insert it into your RelativeLayout UI
definition XML mark-up.


Figure 7-17. Use the left chevron to bring up a child tag pop-up helper dialog and find, select, and double-click Button


Add an android:id parameter named submit_colony so that the Java program logic can reference
the Button UI element, using the android:id="@+id/submit_colony" parameter format, and then you
will be ready to add in your RelativeLayout positioning parameters, which will position the Button
UI element relative to the position of the EditText UI element. This “relative positioning” capability is
what sets the RelativeLayout class and UI layout container type apart from all of the other Android UI
layout container classes. Let’s cover this concept in the next section and take a closer look at some
of the most often used relative positioning parameters, using this UI design, which happens to be
very well-suited for RelativeLayout positioning, as you will soon see.


Aligning Widgets Using RelativeLayout Parameters


After you add your android:id parameter in your

Free download pdf