Disabling of EditText in Android(在 Android 中禁用 EditText)
问题描述
在我的应用程序中,我有一个 EditText,用户只有读取权限而不是写入权限.
In my application, I have an EditText that the user only has Read access not Write access.
在代码中我设置了 android:enabled="false".
虽然EditText的背景变暗了,但是当我点击它时,键盘会弹出,我可以改变文字.
Although the background of EditText changed to dark, when I click on it the keyboard pops up and I can change the text.
我应该设置什么来禁用 EditText?
What should I set to disable EditText?
推荐答案
我相信正确的应该是设置 android:editable="false".
I believe the correct would be to set android:editable="false".
如果你想知道为什么我的链接指向 TextView 的属性,你的答案是因为 EditText 继承自 TextView:
And if you wonder why my link point to the attributes of TextView, you the answer is because EditText inherits from TextView:
EditText 是一层薄薄的外衣将自身配置为的 TextView可编辑.
EditText is a thin veneer over TextView that configures itself to be editable.
更新:
正如下面评论中提到的,editable 已被弃用(从 API 级别 3 开始).您应该改用 inputType(值为 none).
Update:
As mentioned in the comments below, editable is deprecated (since API level 3). You should instead be using inputType (with the value none).
这篇关于在 Android 中禁用 EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Android 中禁用 EditText
基础教程推荐
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 我的 UIImageView 的任务 2022-01-01
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
