drawable下新建mylist_view.xml文件,里面外层标签是selector
<item
android:color="hex_color"//颜色值,#RGB,$ARGB,#RRGGBB,#AARRGGBB
android:state_pressed=["true" | "false"]//是否触摸
android:state_focused=["true" | "false"]//是否获得焦点
android:state_selected=["true" | "false"]//是否被状态
android:state_checkable=["true" | "false"]//是否可选
android:state_checked=["true" | "false"]//是否选中
android:state_enabled=["true" | "false"]//是否可用
android:state_window_focused=["true" | "false"] />//是否窗口聚焦
</selector>
引用
listview
1.listview中设置android:listSelector="@drawable/mylist_view"
2.在ListView的itemandroid:background="@drawable/mylist_view"
3.java中调用
listView.setSelector(drawable); ```
网友评论