When should we use android:clickable
in XML? Should we ever?
Is there any difference between such XML declaration and in-code declaration myButton.setOnClickListener
? I have read the documentation, but I could not find out when and why should I ever use this attribute.
PS. I was implementing an ad SDK and found that their developers were using android:clickable
with WebView
and I was intrigued why did they use it.
As the documentation states, and as far as I know :
clickable
- Defines whether this view reacts to click events. Must be a boolean value, either "true" or "false".
So for example if you just declare a Webview
or View
in your layout.xml
and try to set an OnClickListener
on this views the OnClick
event won't be fired unless you specify the attribute :
android:clickable=true