<item>
-
Defines a drawable to use during certain states, as described by its attributes. Must be a child of a
<selector>
element.
attributes:
- Drawable resource. Required. Reference to a drawable resource.
- Boolean. "true" if this item should be used when the object is pressed (such as when a button is touched/clicked); "false" if this item should be used in the default, non-pressed state.
- Boolean. "true" if this item should be used when the object is focused (such as when a button is highlighted using the trackball/d-pad); "false" if this item should be used in the default, non-focused state.
- Boolean. "true" if this item should be used when the object is selected (such as when a tab is opened); "false" if this item should be used when the object is not selected.
- Boolean. "true" if this item should be used when the object is checkable; "false" if this item should be used when the object is not checkable. (Only useful if the object can transition between a checkable and non-checkable widget.)
- Boolean. "true" if this item should be used when the object is checked; "false" if it should be used when the object is un-checked.
- Boolean. "true" if this item should be used when the object is enabled (capable of receiving touch/click events); "false" if it should be used when the object is disabled.
- Boolean. "true" if this item should be used when the application window has focus (the application is in the foreground), "false" if this item should be used when the application window does not have focus (for example, if the notification shade is pulled down or a dialog appears).
android:drawable
android:state_pressed
android:state_focused
android:state_selected 被选中的状态。在做标签页的时候用到了。一个默认,一个选中。
android:state_checkable
android:state_checked
android:state_enabled
android:state_window_focused
Note: Remember that Android applies the first item in the state list that matches the current state of the object. So, if the first item in the list contains none of the state attributes above, then it is applied every time, which is why your default value should always be last (as demonstrated in the following example).