4

I have an Activity with a ListView, I set the background image to the view programatically. When I scroll down my list, the background image turns to white ( because my theme is Theme.Light.NoTitleBar).

  1. How can I make it scroll with the blue background intact?
  2. If the above point works, how can I change the text color of ListView to white instead of black?

Normal ListView Normal ListView

Scrolling ListView Scrolling ListView

Pressing ListView item Pressing ListView item

Nouran H
  • 1,922
  • 5
  • 18
  • 24

5 Answers5

3

add a attribute on the ListView Tag

android:cacheColorHint="#00000000"// setting as a transparent color
interboy
  • 816
  • 1
  • 11
  • 25
3
  1. Use the attribute android:cacheColorHint="#000000" in ListView Tag
  2. Regarding make TextView's color black or white, you can refer here to make a custom TextView for your ListView row, The extra work you have to do is just add another attribut inside TextView tag like this

    android:textColor="#FFF" //or #FFFFFF for white

Community
  • 1
  • 1
Adil Soomro
  • 37,173
  • 9
  • 101
  • 148
2

This is due because of an optimization. To remove this, just set the cacheColorHint of your listView to transparent, like this: android:cacheColorHint="#00000000"

Full post here: http://android-developers.blogspot.fr/2009/01/why-is-my-list-black-android.html

cjk
  • 44,524
  • 9
  • 79
  • 111
AMerle
  • 4,328
  • 1
  • 26
  • 43
0

You can Wrap that ListView inside on LinearLayout having same background and then remove ListView's Background that should work fine. :)

RPB
  • 15,438
  • 15
  • 52
  • 79
  • this is workaround not a solution and i don't think so i should be down Voted for this answer. – RPB Jun 28 '12 at 12:44
0

Please check this answer. I have got the same issue and it is fixed by putting view = null in adapter side.

Community
  • 1
  • 1
Ahmad Arslan
  • 4,998
  • 8
  • 40
  • 60