ImageButton has a different inheritance chain, that is, it does not extend Button :
ImageButton < ImageView < View
He continues to receive click events.
Here's what happens when you install the click listener for a View :
public void setOnClickListener(OnClickListener l) { if (!isClickable()) { setClickable(true); } mOnClickListener = l; }
Therefore, if you set the listener, android:clickable="false" will change to android:clickable="true" .
and its appearance does not change like a standard button
You must provide a list of display states for the view so that it can set the appropriate image based on android:enabled . Do you have this? Or do you have a single image for your button?
EDIT: You can find information about StateListDrawable here . android:state_enabled is what you need to use in the list to tell the OS which image to use for this state.
EDIT 2: Since you really need to add a listener, you can check inside the listener if (!isEnabled()) { return; } else {/* process the event */} if (!isEnabled()) { return; } else {/* process the event */} if (!isEnabled()) { return; } else {/* process the event */} if (!isEnabled()) { return; } else {/* process the event */} .
Vit Khudenko Nov 19 '11 at 18:49 2011-11-19 18:49
source share