I’ve got an ImageView which I’m setting to setImageResource(R.drawable.someStateListDrawable). Everything works fine, when it’s clicked, it shows the pressed state. However, I’ve made it so that it onClick, the ImageView is set to “setPressed(true)” so that it will remain in the pressed state. But for some reason, its not… Any ideas?
I’ve got an ImageView which I’m setting to setImageResource(R.drawable.someStateListDrawable) . Everything works fine, when
Share
I just had this same problem with a Button. When
onClickI set it to the pressed state (btn.setPressed(true)) but after that the button wasn’t pressed.In case this helps somebody, I finally worked with the selected state. My drawable xml looks like
and at
onClickI now usebtn.setSelected( true ).I don’t know what was the problem with
setPressed, but this worked for me.