2010-08-18 62 views
0

我試圖設置我的togglebutton屬性佈局使用style.xml。 這裏是我的代碼:問題與Android togglebutton

<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" /> 

對於ID = button_toggle_1,我應用樣式(style.xml),這裏是代碼:

<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> 

我可以看到按鍵2和3,但對於按鈕上的文本3與我設定的不同。按鈕3文本=「APAGADO」。從這個測試中,我得出結論,togglebutton根本無法使用style.xml來設置它的屬性。這是真的?還是我做錯了什麼?

如果切換按鈕是「特殊」,任何人都知道原因?這個「特殊」條件也適用於其他事情嗎?

謝謝!

回答

2

您沒有正確引用樣式。它是style="@style/style_name"See documentation

+0

謝謝!相信與否,除了這些togglebutton之外,我的所有其他引用都是正確的。無論如何,我已經在N1上測試過它,並且它完美地工作。再次感謝。 – lwijono 2010-08-19 17:37:04