How to disable an Android button?
Did you try this?
myButton.setEnabled(false);
Update: Thanks to Gwen. Almost forgot that android:clickable
can be set in your XML layout to determine whether a button can be clickable or not.
You can't enable it or disable it in your XML (since your layout is set at runtime), but you can set if it's clickable at the launch of the activity with android:clickable
.
Yes it can be disabled in XML just using:
<Button
android:enabled="false"
/>