我使用的是android-actionbar插件。
我使用以下命令成功添加了一个home操作:
actionBar.setHomeAction(
new IntentAction(this,
DisciplinesController.createIntent(this), R.drawable.back_button));现在我想在按下按钮时更换抽屉……有什么想法吗?
谢谢
发布于 2011-11-25 22:25:33
我在ActionBar GitHub页面https://github.com/johannilsson/android-actionbar/issues/31上找到了这个
我建议你尝试一下mimic-native-api分支中的新版本。然后,您可以简单地在操作上使用setIcon。
所以克隆这个分支,它应该有一个setIcon方法,我稍后会亲自尝试一下。
发布于 2012-05-30 01:51:52
要根据您是否按下按钮来创建不同的图像,请在可绘制文件夹中创建一个如下所示的xml文件:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/menu_tools_green"/>
<item android:state_focused="false"
android:state_pressed="true"
android:drawable="@drawable/menu_tools_green"/>
<item android:state_focused="true"
android:drawable="@drawable/menu_tools_green"/>
<item android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/menu_tools_orange"/>
如你所见,每个州都有一张图片。
问候
https://stackoverflow.com/questions/7682295
复制相似问题