Graphics Programs Reference
In-Depth Information
Figure 2-13
.
Landscape mode with UI
Working
with
Buttons
and
the
Counter
Class
Here, we finally discuss the functioning of an application that updates the rendering
on an OpenGL surface using a layout (that we just created). To load that application
into your workspace, import the archive file
updowncounter.zip
from the
Chapter2
folder.
Inside the
UPDOWN COUNTER
application (
Figures 2-14
and
2-15
), if you browse
the
layout
folder, you will see the files
updown.xml
and
counter.xml
. The
updown.xml
file contains the layout from the previous topic. However, now the
buttons contain ids “up” and “down” defined in the
id.xml
file (inside
res/values
folder), which also contains another
id
“counter,” corresponding to the
TextView
basic styling applied to it.
Buttons are assigned ids so they can be referenced from the
Activity
defined in
Main.java
file. This application contains the Renderer class from the previous ap-
plication with slight modifications.
This application uses an important class
Counter
(this class will also be used in the
Tank Fence
game) to track the number of clicks on the up and down buttons. (The

Search WWH ::

Custom Search