I\'m using the RecyclerView
like below:
Add this below attribute in your Item "my_list_item.xml"
android:descendantFocusability="blocksDescendants"
This works for me !
As many others answered the only way is to combine selectors and new Classes to keep track of the selection, but better to delegate this calculation to the Adapter. The library FlexibleAdapter keeps track of the selections for you, configuration change is also compatible.
Backgrounds color with ripple can now be done without XML part, but in the code to manage dynamic data.
Finally, you can use lot of features with the same library, selection is a tiny basic feature you can have.
Please have a look at the description, Wiki pages and full working example: https://github.com/davideas/FlexibleAdapter
You need to set android:clickable="true"
in the element xml, and if you have more selectors in some view inside your view, you need to set android:duplicateParentState="true"
there too.
Thats works on pre honeycomb apis.
on your design or xml file just place the following lines.
android:clickable="true"
android:focusable="true"
android:background="?android:attr/activatedBackgroundIndicator"