By default, if you click on an item in the ListView, it will turn blue. I changed the element's background color via View.setBackgroundColor(...) , the color has changed, but the blue color disappeared when I clicked. How to return it without using xml ?

I asked here because I do not know how to formulate a question in English for Google)

  • Assign the view as a selector drawable background with the desired values ​​for the default state and the pressed state . - falstaf
  • Are there any simpler options? - Helisia
  • one
    Is this difficult? - falstaf
  • Honestly, for me - yes. I thought that everything could be done in one / two lines of java code. - Helisia

2 answers 2

Option for the lazy (I use it myself sometimes) holo-colors download List Selector and change the right places as @falstaf said (you can take it from the source, but it's more convenient for me)

    I think it would be useful to study this article .