我有一系列像redo, undo, choose, delete这样的图片。我需要了解如何实现当用户点击redo,它将突出显示。当用户单击undo时,redo按钮返回到默认状态,undo按钮高亮显示。
我有以下redo按钮的实现
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="false"
android:drawable="@drawable/redo_off" />
<item
android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/redo_on" />
<item
android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/redo_on" />
<item
android:state_enabled="true"
android:drawable="@drawable/redo_off" />
</selector>发布于 2015-07-15 23:41:03
您可能需要在它们各自的单击侦听器中设置这些按钮的所需状态。不确定是否可以通过selector xml文件完成此操作。
发布于 2015-07-16 00:27:37
下面是让方法切换并传递int值的技巧,如下所示
private void toggleButton(int value){
switch(value){
case 1:
//set enabled background color of the redo button
//set disabled background color of the undo button
//set disabled background color of the choose button
//set disabled background color of the delete button
break;
case 2:
//set disabled background color of the redo button
//set enabled background color of the undo button
//set disabled background color of the choose button
//set disabled background color of the delete button
break;
case 3:
//set disabled background color of the redo button
//set disabled background color of the undo button
//set enabled background color of the choose button
//set disabled background color of the delete button
break;
case 4:
//set disabled background color of the redo button
//set disabled background color of the undo button
//set disabled background color of the choose button
//set enabled background color of the delete button
break;
}
}onYour按钮单击add call this method如果单击redo按钮调用
toggleButton(1);如果您单击undo按钮调用
toggleButton(2);如果您点击选择按键呼叫
toggleButton(3);如果你点击删除按钮调用
toggleButton(4);https://stackoverflow.com/questions/31434728
复制相似问题