如何禁用Android按钮? [英] How to disable an Android button?

查看:32
本文介绍了如何禁用Android按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个布局,其中包含两个按钮,下一个和上一个.在按钮之间,我生成了一些动态视图.所以当我第一次启动应用程序时,我想禁用上一个"按钮,因为不会有任何以前的视图.当没有更多视图可显示时,我还想禁用下一步"按钮.无论如何要禁用按钮?

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); 

更新:感谢格温.差点忘了android:clickable 可以在你的 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆