What is a difference between Spannable and String ?
What is a difference between Spannable and String ?
The main difference between Spannable
and String
in Android is that Spannable
allows you to apply formatting spans to specific portions of the text, while String
is a plain, immutable sequence of characters without any formatting[1][2].
Some key points:
String
is immutable and cannot be changed once created, while Spannable
allows you to add, remove or modify formatting spans after creation[1][3].Spannable
is a subinterface of Spanned
, which represents a CharSequence
with attached formatting spans[1][3].SpannableString
is a concrete implementation of Spannable
that stores the text and spans in memory[1][3].setText()
on a TextView
with a Spannable
, it creates a copy of the Spannable
as a SpannedString
which has immutable text and spans[2].entry
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào