Game Development Reference
In-Depth Information
The custom GLSurfaceView class to use in this view is specified by the following statement, which is
the complete name of the class that includes the package that it is in:
robs.demo.TestDemoComplete.MyGLSurfaceView
The id for this view is specified by the following statement:
android:id="@+id/MyGLSurfaceView"
The “ @ ” symbol tells the compiler to parse and expand the rest of the string as an identity resource.
The “ + ” tells the compiler that this new id must be added to the resources file located in the gen/R.
java file. “MyGLSurfaceView” is the actual id (see Listing 2-4).
Listing 2-4. XML Layout for Multiple View OpenGL ES Application
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/Text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"/>
<EditText
android:id="@+id/EditTextBox1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"/>
<robs.demo.TestDemoComplete.MyGLSurfaceView
android:id="@+id/MyGLSurfaceView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
The Activity Class and GLSurfaceView Class
The XML layout in the preceding section is set to be the user interface by the statement
setContentView() located in our Activity class.
Within the Activity class, we use the findViewById() function to get a reference to the newly created
MyGLSurfaceView object, so we can reference it in our Activity class.
A new constructor is added to the MyGLSurfaceView class. This is needed because of our addition
of the MyGLSurfaceView class into the XML layout (see Listing 2-5).
 
Search WWH ::




Custom Search