Using the ListView Custom Adapter with Standard Android Themes

I am developing an application on Honeycomb with a ListView list. When using the usual ArrayAdapter to feed the contents of the ListView, I can pass it a built-in layout, for example Android.R.layout.simple_selectable_list_item . When creating an element compatible with the overall cellular feel, a clickable element is created with good fading animation.

However, if I decide to use my own custom layout (or create a custom adapter), I no longer have animation when you focus or select an item in a ListView. I could create my own animation, but I would prefer to use the default Holo theme when developing for Honeycomb for simplicity and consistency.

I do not understand how to do this, and could not find anyone else with my struggle (maybe I was looking for the wrong conditions or missed something obvious!). Anyone have any suggestions? I believe that this is due to the definition of some style or theme in the XML file for the layout, but I did not understand where to place this or what might be the content.

Thanks!

+6
source share
1 answer

Got: I had to remove all the links to android: listSelector and android: background for my ListView. Then i added

android:background=?android:attr/listChoiceBackgroundIndicator 

for my top level view for ListView row layout.

+6
source

Source: https://habr.com/ru/post/890989/


All Articles