Android的TextView.getText()返回类型 [英] Android TextView.getText() return type
本文介绍了Android的TextView.getText()返回类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么 TextView.getText()
返回的的CharSequence
代替字符串
? (字符串是CharSequence的实现)
Why does TextView.getText()
return a CharSequence
instead of a String
? (String is the implementation of the CharSequence)
推荐答案
由于它可能包含 Spannable
对象。从文档:
Because it might contain a Spannable
object. From the doc:
如果的setText()
调用了 BufferType.SPANNABLE
的参数或
BufferType.EDITABLE
,你可以从这个方法将返回值
Spannable
或编辑
,分别为。
If
setText()
was called with an argument ofBufferType.SPANNABLE
orBufferType.EDITABLE
, you can cast the return value from this method toSpannable
orEditable
, respectively.
这篇关于Android的TextView.getText()返回类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文