首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >系列ImageButton突出显示

系列ImageButton突出显示
EN

Stack Overflow用户
提问于 2015-07-15 23:29:47
回答 2查看 30关注 0票数 0

我有一系列像redo, undo, choose, delete这样的图片。我需要了解如何实现当用户点击redo,它将突出显示。当用户单击undo时,redo按钮返回到默认状态,undo按钮高亮显示。

我有以下redo按钮的实现

代码语言:javascript
复制
<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>
EN

回答 2

Stack Overflow用户

发布于 2015-07-15 23:41:03

您可能需要在它们各自的单击侦听器中设置这些按钮的所需状态。不确定是否可以通过selector xml文件完成此操作。

票数 1
EN

Stack Overflow用户

发布于 2015-07-16 00:27:37

下面是让方法切换并传递int值的技巧,如下所示

代码语言:javascript
复制
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按钮调用

代码语言:javascript
复制
toggleButton(1);

如果您单击undo按钮调用

代码语言:javascript
复制
toggleButton(2);

如果您点击选择按键呼叫

代码语言:javascript
复制
toggleButton(3);

如果你点击删除按钮调用

代码语言:javascript
复制
toggleButton(4);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31434728

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档