In an Android application, I have a TextView GridView holding created by the adapter. In this TextView, I add an icon that has three states (click, select, and default). I removed the default GridView selector with android:listSelector="#00000000", and I would like the selected icon state to be displayed instead. But although the pressed state works (i.e., when the TextView is pressed, the pressed version of the icons is displayed), which is not indicated.
I tried these tricks (found in various places on the Internet), but it didn’t work either:
setting
android:descendantFocusability="afterDescendants"
or
android:drawSelectorOnTop="true"
or (in TextViews)
android:duplicateParentState="true" />
And if I set the TextView to focus, it will focus regardless of the GridView (i.e. clicking on it does not call the GridView onClick method ...)
The icon is defined in the XML file as follows:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/ic_flag_bg_pressed"/>
<item android:state_focused="false"
android:state_pressed="true"
android:drawable="@drawable/ic_flag_bg_pressed"/>
<item android:state_focused="true"
android:drawable="@drawable/ic_flag_bg_selected"/>
<item android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/ic_flag_bg_default"/>
</selector>
GridView ?