Game Development Reference
In-Depth Information
}
}
This fragment defines the main activity or class that controls the life cycle of the application. The
onCreate method will be called once when the application starts, and its job is to set the content layout
or GUI for the application.
You should also have a basic understanding of how GUIs are created using XML. Look at the next
fragment. Can you tell what it does?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/doom_iv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/doom"
android:focusableInTouchMode="true" android:focusable="true"/>
<ImageButton android:id="@+id/btn_upleft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:src="@drawable/img1" />
</RelativeLayout>
This code defines a relative layout. In a relative layout, widgets are placed relative to each other
(sometimes overlapping). In this case, there is an image view that fills the entire screen. This image will
display as the background the file called doom.png stored in the res/drawable folder of the project, and
receive key and touch events. In the lower left of the screen, overlapping the image view, an image
button with the ID btn_upleft will be displayed.
Need an Android Tutorial?
There are a lot of concepts related to Android development, and it is impossible to remember every detail
about activities, views, and layouts. A handy place to access this information quickly is the Android tutorial:
http://developer.android.com/
The ultimate guide for Android developers—the latest releases, downloads, SDK Quick Start, version
notes, native development tools, and previous releases—can be found here:
http://developer.android.com/sdk/1.6_r1/index.html
Throughout this topic (especially in the chapters dealing with native code), I make extensive use of
the Android Software Development Kit (SDK) command tools (for system administrator tasks). Thus,
 
Search WWH ::




Custom Search