android 中textview editable,Android: How to make TextView editable?

这篇博客探讨了Android中TextView和EditText的区别。TextView虽然具备编辑文本的能力,但不内置编辑支持,比如没有内置的光标行为控制。EditText则不同,它的默认可编辑性为true,并使用Editable的CharSequence实现,允许文本的动态修改。如果你需要一个有时可以切换编辑状态的文本组件,EditText是理想选择。
摘要由CSDN通过智能技术生成

TextView defines all capabilities found on EditText, but doesn't have built-in support to them. Some main differences on EditText:

a) Method getDefaultEditable() returns true. This is only a mark that defines this subclass as editable.

b) A movement method. Is an object that control the cursor behavior (position, backward/forward moves - that may change in some languages, etc). In opposition, TextView just returns null, because is not cursor anyway.

c) Method CharSequence getText(). TextView returns a single String for that. EditText uses a specific char sequence implementation (Editable) that represents a mutable text buffer.

Because that, we can't think about TextView like a restrained EditText. TextView sketch the editoring interface, but not implement itself.

If you need a text component that you can switch off editing sometimes, you are looking for the EditText component.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值