android - ListFragment Item Selected Background -


I have a list section with some selection, which opens up new pieces. Part of me wishes to make every item in the list (I have 6) for a different color set when it is selected and I call my getListView (). SetItemChecked (index, true); Is it possible to set different backgrounds or should they all be equal? Thank you.

Yes, you can use them in a different background you stat list Drevbl for each of them Will be required to select the desired background based on the condition of the item.

If you see the demo piece of layout, list items using this layout:

  setListAdapter (new Arre adapter & lt; String & gt; ( GetActivity (), android.R.layout.simple_list_item_activated_1, Shakespeare.TITLES));   

This is the layout:

  & lt; TextView xmlns: android = "http://schemas.android.com/apk/res/android" android: id = "@ android: id / text 1" Android: Layout_width = "Match_parent" Android: Layout_height = "Wrap_content" Android : TextAppearance = "android: attr / textAppearanceLarge" android: gravity = "Center_vertical" android: background = "? Android: ATR / activated Bakfang indicator" Android: Minhait = "? Android: Attr / Listprrirdaitmahit" / & gt;   

And Android: The background set here is blurred for a deep non-hollow topic:

   & Lt; Item Android: Dragon = "@color / transparent" /> & Lt; / Selector & gt;   

Just write your own design, which uses different designs for their active state.

(Note that I'm assuming that you went to a wide range of working with Honeycomb where the active position. The last stage versions, it is not clear as hard - but you A layout subclass that applies checksable and needs to be written in its background based on the status of the investigation)

Comments