Graphics Programs Reference
In-Depth Information
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="
http://schemas.android.com/apk/
android:id="@id/up"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:contentDescription="@string/app_name"
android:minHeight="60dp"
android:text="@string/fire" />
As I mentioned already, you also need to define the string and item (id) resources.
Before I talk about the code in
Main
class, copy another file -
Counter.java
,
from the
UPDOWN COUNTER
application to the
src
folder of the
TANK FENCE 3
application.
In the
Main
class, clear all the lines of code inside the
onCreate()
method
after the variable
rllp
(of type
RelativeLayout.LayoutParams
) is defined.
Then, add the lines of code given in
Listing 6-4
.
Note
As with other code listings in this topic,
Listing 6-4
is from
the final (completed) copy of the file we are working with. So, al-
though we are working with the
TANK FENCE 3
application,
List-
ing 6-4
shows code from the
TANK FENCE GAME 1
application -
containing the final copy of the
Main.java
file. (The completed
copies may contain slightly modified variable names.)
Listing 6-4.
TANK FENCE GAME 1/src/com/apress/android/tankfencegame1/
Main.java
rl.setGravity(Gravity.BOTTOM);
LayoutInflater inflater = (LayoutInflater)

Search WWH ::

Custom Search