I've made a ListView in my project, but I find that when I drag it up and down or I click one item, the item's background will change to be yellow(the default background in Android?). But I don't wanna to be that, I wanna: No change about the item's background when drag or click it. Can any way make it?
Asked
Active
Viewed 400 times
1 Answers
1
Specify a background (Color/Drawable) to the List-Item template.
Suppose you are using the default simple_list_item, it consists of only one TextView, add a background to it (instead of the default):
<TextView
android:background="#000"
...
In this case, it will not change background when clicking or dragging.
-- Update --
In Android, the background is by default some kind of "StateListDrawable" and it will response to "State" Changes in its appearance. Specifying a background breaks the default implementation and make the background to be a simple Drawable without states.

xandy
- 27,357
- 8
- 59
- 64
-
Thank you xandy!I've try your first answer,but that seems not work.I have specified the ListView and TextView(list item) background , but nothing changed ,anything wrong?? – Rocky Jun 30 '11 at 02:25
-
PS:I wanna give the TextView transparent background.('code' android:background="#00000000") – Rocky Jun 30 '11 at 02:45
-
ok,I checked this site and found the solution i need. My solution is : > ListView list = (ListView)findViewById(R.id.list); list.setSelector(this.getResources().getDrawable(R.drawable.transparentPNG)); Note:transparentPNG is the .png file for the selector bg. Here is the link about the solution for my problem. [link]( http://stackoverflow.com/questions/5809943/listview-shows-orange-background-when-clicked) – Rocky Jun 30 '11 at 03:19