【发布时间】:2012-09-11 09:04:15
【问题描述】:
我想在按钮不可点击时更改按钮的背景。我为此使用了选择器,但在按钮仍然不可点击的情况下它不起作用。
这是选择器文件:
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/button_lightgrey" />
<item android:state_pressed="true" android:state_enabled="true" android:drawable="@drawable/button_blue"/>
<item android:state_focused="true" android:drawable="@drawable/button_darkgreen" />
<item android:drawable="@drawable/button_lightgreen" />
</selector>
这是我使用此选择器文件的按钮:
<Button
android:id="@+id/PrevButton"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_marginLeft="5.0dip"
android:layout_weight="1.0"
android:background="@drawable/ibtn"
android:onClick="onPrevButtonClick"
android:text="Prev" />
请帮助我。所有其他功能都在选择器文件中工作,但只有不可点击的按钮案例不起作用。谢谢
【问题讨论】:
-
希望对您有所帮助:stackoverflow.com/questions/3738886/…>
-
先生,我想让选择器在按钮不可点击时工作。其他状态正在工作,但只有这个不工作。
-
你想要一个禁用状态的选择器吗? “不可点击”是什么意思?
-
是的先生,我需要禁用状态的选择器。
标签: android