A little background info: I am a C++ developer who has worked very
little with Java. Picking up Java wasn't very difficult since I know C+
+, but I am still playing around with the SDK. (In C++, my favorite
SDK/API is Qt)

Anyway, I am trying to stick to the Model-View-Controller design
philosophy, and was setting up the UI in XML. However, it is not
working out the way I wanted it too. I am trying to write a simple app
(to help get started with learning the SDK), where there are 4
buttons, all of which cause a different operation on a value in a
textview. For example, the textview starts out at 100, and I have 4
buttons: +1, -1, +5, -5. When you press +1, it adds 1 to the value in
the textview. When you press -5, it subtracts 5 from the value in the
textview, etc etc...

That part is working fine. However, I am trying to setup the UI as
follows:

[TextView]
[+1]    [-1]
[+5]    [-5]

Basically, I want all the + in one column, and all the - in another
column. I figured I would use a relativeLayout, however, it is not
working the way I want it to. I am getting the following
[TextView]  [-5]
[+1]
[+5]
(the -1 button is totally missing)

I have tried to narrow down possible errors in my code, and I have
come to the conclusion that either I am using android:layout_toRightOf
wrong, or I misunderstand how this command is implemented.

Here is my main.xml file:
(note: bu1p = button for +1, bu1m = button for -1 [p=positive
m=minus]. I also have a custom button in there, so there are really 6
buttons in total)

<?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"
        >
        <TextView
                android:id = "@+id/nums"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize = "20sp"
        android:text = "100"
    />
        <Button
                android:id = "@+id/bu1p"
                android:layout_width="70sp"
                android:layout_height="wrap_content"
        android:text = "+1"
        android:layout_below="@id/nums"
        />
        <Button
                android:id = "@+id/bu1m"
                android:layout_width="70sp"
                android:layout_height="wrap_content"
        android:text = "+1"
        android:layout_toRightOf="@id/bu1p"
        />

        <Button
                android:id = "@+id/bu5p"
                android:layout_width="70sp"
                android:layout_height="wrap_content"
        android:text = "+5"
        android:layout_below="@id/bu1p"
        />
        <Button
                android:id = "@+id/bu5m"
                android:layout_width="70sp"
                android:layout_height="wrap_content"
        android:text = "-5"
        android:layout_toRightOf="@id/bucm"
        />
        <Button
                android:id = "@+id/bucp"
                android:layout_width="70sp"
                android:layout_height="wrap_content"
                android:text = "Custom"
        android:layout_below="@id/bu5p"
        />
        <Button
                android:id = "@+id/bucm"
                android:layout_width="70sp"
                android:layout_height="wrap_content"
                android:text = "Custom"
               android:layout_toRightOf="@id/bu5p"
        />
</RelativeLayout>

Again, just to clarify, this is how I want the UI to look:
[TextView]
[+1]   [-1]
[+5]   [-5]
[+c]   [-c]

(c is the custom value)

Any help is greatly appreciated. Sorry for the weird tab formatting,
it didn't copy over correctly from Eclipse.

Thank you,
Jon

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to