Hello there, I am playing with backgrounds for an app with some listviews. What I want is a custom highlight programmatically on pressing a list item. It needs to be done programmatically, as this app creates some background drawables programmatically. That seams to be easy with just creating an appropriate StateListDrawable, but still something is wrong with my implementation. I experimented with state attributes of different kinds, but it still doesn't work. The effect atm is that the background in a listview item is just black, regardless if pressed or not.
I use the following code to create the StateListDrawable: public StateListDrawable createSelectedUnSelectedDrawable( Drawable normalDrawable, Drawable selectedDrawable) { int[] notMarked = new int[] { - R.attr.state_selected, - R.attr.state_pressed }; int[] pressed = new int[] { R.attr.state_pressed }; int[] selected = new int[] { R.attr.state_selected, - R.attr.state_pressed }; StateListDrawable sld = new StateListDrawable(); sld.addState( notMarked, normalDrawable ); sld.addState( pressed, selectedDrawable); sld.addState( selected, selectedDrawable ); return sld; } Can someone tell me whats wrong with this and how to fix it? R. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en