I am programatically setting the pressed state of an ImageButton.
Problem is when I press on it, the state does not change at all. I tried using state_focused
and a few others but the button does not change at all. Do you know why my ImageButton is not changing its image when pressed?
_pauseButton = new ImageButton(_context);
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(new int[] {},
getResources().getDrawable(R.drawable.pause));
stateListDrawable.addState(new int[] {android.R.attr.state_pressed},
getResources().getDrawable(R.drawable.pausepressed));
_pauseButton.setImageDrawable(stateListDrawable);
The default state image does show up correctly, but when its pressed, there is no change.