Hey guys,

First off - thanks to all of you experienced engineers helping us
n00bs. Your feedback has been invaluable to me learning the Android
platform.

What I am trying to do: Have a button blank when the user enters into
a layout. When they touch the button I'd like it to change ON/OFF to
"Blue" or "Red". I've got the ON/OFF state working, but I need to
figure out how to add a third state.

The issue at hand: How do I add three states to a toggle button? I've
spent a week attempting to figure it out and am at a loss. The
tutorials say use toggle() or state(false) / (true) but I've been able
to figure out what exactly I'm doing. I've love to handle this in xml
and leave java for recording values.

Here's my xml setup -

Main layout:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg_tes2" >

      <ImageButton
    android:id="@+id/android_button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="123px"
        android:layout_y="127px"
    android:background="@drawable/my_button2"/>

     <ToggleButton android:id="@+id/toggle_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textOn="Red"
    android:textOff="Blue"
    android:layout_x="160px"
        android:layout_y="58px"
    android:background="@drawable/my_button"/>

     <ToggleButton android:id="@+id/toggle_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textOn="Red"
    android:textOff="Blue"
    android:layout_x="84px"
        android:layout_y="59px"
    android:background="@drawable/my_button"/>

      <RadioButton android:id="@+id/radio_blue"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Blue"/>

</AbsoluteLayout>

@drawable/my_button

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android";>
    <item android:state_focused="true" android:state_pressed="false"
android:drawable="@drawable/wat3" />
    <item android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/wat3" />
    <item android:state_focused="false" android:state_pressed="false"
android:drawable="@drawable/wat" />
    <item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/wat2" />
</selector>



thanks for the help!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to