tags:

views:

75

answers:

1

I tried to set up my togglebutton properties layout using style.xml. Here's my code:

    <ToggleButton android:id="@+id/button_toggle_1" style="button_test_1"/>

    <ToggleButton android:id="@+id/button_toggle_2"
        android:textOff="test2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <ToggleButton android:id="@+id/button_toggle_3" style="button_test_3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

For ID=button_toggle_1, I apply a style (style.xml), here's the code:

<style name="button_test_1">
    <item name="android:textOff">test1</item>
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
</style>

<style name="button_test_3">
    <item name="android:textOff">test3</item>
</style>

I can see button 2 and 3 but the text for button 3 is different from what I set it to be. button 3 text = "APAGADO". From this test, I conclude that togglebutton simply cannot set its properties using style.xml. Is this true? or did I do something wrong?

If toggle button is "special", anyone knows the reason why? is this "special" condition applies to other things as well?

Thanks!

A: 

You are not referencing the styles correctly. It is style="@style/style_name". See documentation.

Qberticus
Thanks! Believe it or not, I got all my other referencing correct except for these togglebutton. Anyway, I've tested this on N1 and it works perfectly. Thanks again.