Home>

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.

  • Previous js + html5 to achieve side-sliding page effect
  • Next Angular2 questions about @ angular/cli default port number configuration
  • Trends