为什么 TextView.getText()
返回的是 CharSequence
而不是 String
?
(String是CharSequence的实现)
最佳答案
因为它可能包含一个 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 - android 中 TextView.getText() 的返回类型是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21915797/