Game Development Reference
In-Depth Information
<!-- Other controls: Map, Open, strafe -->
<!-- This XML has been removed for simplicity -->
<!-- See the file doom.xml for details -->
</RelativeLayout>
Table 5-3. Main Attributes of doom.xml
Attribute
Meaning
android:id="@+id/doom_iv"
Defines the ID of the widget, which can be used for
programmatic access. The format must be @+id/NAME .
android:layout_width="fill_parent"
Defines the width of the widget. The values can be
fill_parent or wrap_content .
android:focusableInTouchMode="true"
Specifies that the widget should be focusable and
receive touch events from the main activity.
android:focusable="true"
Specifies that the widget should be focusable and
receive key events from the main activity.
android:src="@drawable/up"
Defines the bitmap source of the widget (applies to
image view only). The format is @drawable/NAME where
NAME is the bitmap filename saved under the
res/drawable folder of the project.
android:layout_alignParentBottom="true"
Tells the relative layout to align the widget to the bottom
of the parent, possibly overlapping other widgets.
android:layout_alignParentLeft="true"
Tells the relative layout to align the widget to the left of
the parent, possibly overlapping other widgets.
android:visibility="gone"
Sets the visibility of the widget. Possible values are
visible (default value) or gone (indicates the widget
occupies no space).
Once the GUI is all set, the next step is to provide a menu and handlers for the application.
Menu and Selection Handlers
The application menu can be easily defined by overriding the following methods:
onCreateOptionsMenu(Menu menu) : Override this method to add items to the
menu. To do this, use menu.add(groupId, itemId, order, Menu Label) ,
where groupId is the ID of the group for this item. This can be used to
define groups of items for batch state changes. itemId is the unique
item ID. order is the order for the item.
onOptionsItemSelected(MenuItem item) : Override this method to
process menu selections. The item selected can be obtained with
item.getItemId() .
 
 
Search WWH ::




Custom Search