Hmm, the git example was remarkably unhelpful. A few comments in the code would be nice.
Anyway, here's what I'm trying to do: My selector XML looks like this: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:drawable="@drawable/my_drawable_checked" /> <!-- dirty --> <item android:state_pressed="true" android:drawable="@drawable/my_drawable_pressed" /> <!-- pressed --> <item android:drawable="@drawable/my_drawable_default" /> <!-- default --> </selector> I set the onTouch listener of the ImageView like this: setOnTouchListener( new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent gesture ) { switch( gesture.getAction() ) { case MotionEvent.ACTION_DOWN: setPressed( true ); break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: setPressed(false); break; } return false; } }); The part above works, I get the correct pressed image when I touch the image on-screen. The issue comes with how to handle the "checked" state. ImageView lacks a setChecked() method. This means I need to define some state that is toggled by onClick and also read by the image framework as state android:state_checked. The git code to extend the drawable state is largely uncommented and far too general for me to understand which parts apply to my situation. Is there a write-up somewhere of how drawable state works in conjunction with an xml selector file? -- 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