【发布时间】:2011-12-07 06:46:14
【问题描述】:
如何为“state_pressed”定义 Android 按钮图像 Java中的“android:state_focused”?
例如,如何在 Java 中实现 XML 的等价物
http://developer.android.com/reference/android/widget/ImageButton.html
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/button_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/button_focused" /> <!-- focused -->
<item android:drawable="@drawable/button_normal" /> <!-- default -->
</selector>
【问题讨论】: