3
android docsから、TextView
,EDITABLE
,NORMAL
およびSPANNABLE
の3種類のバッファがあります。それぞれの違いは何ですか?共通のユースケースは何ですか? >のみを返すSpannableと編集可能 -TextView BufferType
android docsから、TextView
,EDITABLE
,NORMAL
およびSPANNABLE
の3種類のバッファがあります。それぞれの違いは何ですか?共通のユースケースは何ですか? >のみを返すSpannableと編集可能 -TextView BufferType
TextView.BufferType
等、単一のTextViewで別の色、スタイル
EDITABLE
を設定し、挿入などのruntime
でTextView
を変更するために使用されます。
NORMAL
- > CharSequenceのみを返します。
SPANNABLE
- >返されるのはSpannableのみです。
ここにはTextView.BufferType.EDITABLE
が使用されています。
yourTextView.setText("is a textView of Editable BufferType",TextView.BufferType.EDITABLE);
/* here i insert the textView value in a runtime*/
Editable editable = youTextView.getEditableText();
editable.insert(0,"This "); //0 is the index value where the "TEXT" will be placed
出力リレー:
ここThis is a textView of Editable BufferType
TextView.BufferType.SPANNABLE
用途で、これはまた、引数に変更することによって、(編集可能なので、spannableまたは編集可能な書かれた)TextView.BufferType.EDITABLE
によって書かれ
yourTextView.setText("textView of Spannable BufferType",TextView.BufferType.SPANNABLE);
/* here i change the color in a textview*/
Spannable span = (Spannable)yourTextView.getText();
span.setSpan(new ForegroundColorSpan(0xff0000ff),11,"textView of Spannable BufferType".length(),Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
出力:
textView of `Spannable BufferType`(Spannable BufferType are in blue color)