如何禁用一个Android按钮? [英] How to disable an Android button?
问题描述
我已经创建了一个包含两个按钮,下一步,previous布局。在按键之间,我产生了一些动态视图。所以,当我第一次启动应用程序,我想禁用previous按钮,因为不会有任何previous意见。我也想禁用下一步按钮时,有没有更多的视图显示。反正有禁用按钮?
I have created a layout that contains two buttons, Next and Previous. In between the buttons I'm generating some dynamic views. So when I first launch the application I want to disable the "Previous" button since there wont be any previous views. I also want to disable the "Next" button when there are not more views to display. Is there anyway to disable the buttons?
推荐答案
你试试这个?
myButton.setEnabled(false);
更新:多亏了格温。差点忘了说机器人:可点击
可以在你的XML布局设置,以确定按钮是否可以点击,或者不
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.
这篇关于如何禁用一个Android按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!