Customize the item click effect of android listview
Foreword:
Friends who develop listview android know a lot of it,There are many articles about android listview item click effects on the Internet.I have also read a lot of articles about listview, and here are some good articles.You can refer to it,
It's really unwise to get this effect before,I added a selector xml file to the item layout file to achieve the item click effect of the listview..
This is another way of recording how I use it later:
Create a selector.xml file for the item as follows:
<?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/item_selector_pressed" />
<item android:state_focused="true" android:drawable="@ drawable/item_selector_pressed" />
<item android:drawable="@ android:color/transparent" />
</selector>
Introduce android:listselector="@ drawable/item_selector" where listview is needed
In fact, this can only be blamed when you usually write the selector file. It is easy to ignore<item android:drawable="@ android:color/transparent" />This leads to a lot of detours to complete.Keep this in mind.
Related articles
- Android ListView click item to make item expand the implementation code
- Android programming to implement Listview click to expand and hide methods
- Android programming to add click event function to part area of item in ListView
- Android development implement ListView click item to change color function example
- Android implementation of ClickView color change examples
- Android implementation for ListView to set both the background when clicked and the background after click release
- ListView of Android development implements partial refresh of Item
- Android development to achieve ListView click to expand and collapse effect example