android listview 设置点击效果selector
原创
©著作权归作者所有:来自51CTO博客作者jdsjlzx的原创作品,请联系作者获取转载授权,否则将追究法律责任
在此Item项布局文件中添加android:background="@drawable/list_selector"
list_selector.xml:
<?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/list_selector_background_focus" />
<item android:state_selected="true" android:drawable="@drawable/list_selector_background_focus" />
<item android:state_focused="true" android:drawable="@drawable/list_selector_background_focus" />
<!-- default drawable -->
<item android:drawable="@drawable/list_selector_background" />
</selector>