Android按钮操作

时间:2012-11-29 11:30:57

标签: android

我创建了2个不同状态的按钮,我也创建了这个buyton的选择器:     

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/level1_calm" />
    <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/level1_on_click" />
    <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/level1_on_click" />
    <item android:drawable="@drawable/level1_calm" />
</selector>

但是我如何只为所有按钮使用一个选择器,或者禁止它 我的意思是我可以在这里使用一些变量,如下所示:

<?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/level`$Number_button`_calm" />
    <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/level`$Number_button`_on_click" />
    <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/level`$Number_button`_on_click" />
    <item android:drawable="@drawable/level`$Number_button`_calm" />
</selector>

0 个答案:

没有答案