سؤال

Why does TextView.getText() return a CharSequence instead of a String?
(String is the implementation of the CharSequence)

هل كانت مفيدة؟

المحلول

Because it might contain a Spannable object. From the doc:

If setText() was called with an argument of BufferType.SPANNABLE or BufferType.EDITABLE, you can cast the return value from this method to Spannable or Editable, respectively.

نصائح أخرى

it actually returns Editable and not CharSequence but you can store it in a String variable by calling toString() on it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top