在我的应用我有一个EditText。我希望用户只具有读取权限没有写入权限。
在code口设置安卓启用=假
。虽然的EditText的背景改为黑色,当我点击它在弹出键盘了,我可以改变文本。
In my application I have an EditText. I want user just has read access not write access.
In code I set android:enabled="false"
. Although the background of EditText changed to dark, when I click on it the keyboard pops up up and I can change text.
我应该怎么办? 谢谢
我认为正确的是设置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.
更新:
正如在下面的意见,编辑
是德precated(的)。而应该使用inputType (与值无
)。
Update:
As mentioned in the comments below, editable
is deprecated (since API level 3). You should instead be using inputType
(with the value none
).