GridView item list selector for multiple items not working in Android GridView item list selector for multiple items not working in Android android android

GridView item list selector for multiple items not working in Android


I'm not sure it's the right solution, but I set this for the android:background on my list items:

<selector xmlns:android="http://schemas.android.com/apk/res/android"        android:exitFadeDuration="@android:integer/config_mediumAnimTime" >    <!-- I never see this one - the grid items are not focusable -->    <item android:state_pressed="false" android:state_focused="true" android:drawable="@drawable/list_focused" />    <!-- while pressed -->    <item android:state_pressed="true" android:drawable="@drawable/pressed_background" />    <!-- while selected in actionmode -->    <item android:state_activated="true" android:drawable="@color/pressed" />    <item android:drawable="@android:color/transparent" /></selector>

I did not set the android:listSelector attribute on the grid view.


Give padding in your grid item.Maintain bean class for each object in grid adapter to track object is selected or unselected.Based on this value you can update your grid item background color acc to state selected/unselected.Update the object value in onitemclieck listner and also view background.


this can be achieved by tracking the selected items and changing their backgrounds inside the adapter.

I guess you will get little help from this post