From: http://stackoverflow.com/questions/15615823/setenabled-vs-setclickable-what-is-the-difference

setEnabled() vs setClickable(), what is the difference?



setEnabled() vs setClickable(), what is the difference?_sed



up vote 10 down vote favorite



Until now, when I wanted to block the user from pressing the button, I would set thebutton.setClickable(false);, and usually change the text to some kind of gray (to let the user know that the button is disabled). today I stumble on the setEnabled() property.

So I went to the documentation to see that:

setEnabled(boolean enabled)
   Set the enabled state of this view.

What the hell is that mean? what is the difference between enable state/clickable state and disabled state/ not clickable state? Some one could please explain what is the difference between doing what I was doing until now (using the clickable property) and using the setEnable property? what should be used when? I search SO but could not find something related.

Thanks.



android android-button clickable



 


add a comment

share | improve this question


edited Mar 25 '13 at 13:38







Mar 25 '13 at 13:11






Emil Adz
12.4k 11 41 70



1 Answer


active oldest votes


up vote 16 down vote accepted


What the hell is that mean?

Quoting the Wikipedia page for "GUI widget":

In the context of an application, a widget may be enabled or disabled at a given point in time. An enabled widget has the capacity to respond to events, such as keystrokes or mouse actions. A widget that cannot respond to such events is considered disabled. The appearance of disabled widget is typically different from an enabled widget; the disabled widget may be drawn in a lighter color, or may be visually obscured in some way. See the image to the right for an example.

This concept has been around for a couple of decades and can be found in most GUI frameworks.

what is the difference between enable state/clickable state and disabled state/ not clickable state?

In Android, a widget that is not clickable will not respond to click events. A disabled widget not only is not clickable, but it also visually indicates that it is disabled.

what do you mean by: "..since it makes the Button visually "disabled"? how does it changes it visually?

What makes a Button look and respond like a Button is its background, which is a StateListDrawable. There is a specific image used for the disabled state.



 

share | improve this answer


Mar 25 '13 at 13:46






CommonsWare
414k 35 864 934