See Deepa answer for the solution 🙂
I read all of the solution given in StackOverFlow but none seems to work in my case. The thing is I have several button in my app, which will all react differently onto user action. For exemple, when the app is launched, all the button but two are disabled. So i set the default drawable onto my XML. The when I open a file all of them are clickable but some of those, when pressed need to stay pressed (I’ve done that) but the others just need to be pressed and then unpressed which I can’t do. By the way, all of the button got different background, that is why I do not use selector. Here are some printscreen :


So as you can see I manage the default state and the “checked state” (pressed for “ever”) but I can’t set a clicked state that just press the button then, when the action is finished return into the unpressed state. Because I know that the onClick is call after the touch so it doesn’t work to.
Try this..
i hope it helpful to you…