如何才能发现TextView是否包含SpannableStringBuilder而不是纯文本?我需要更改TextView的文本大小,但如果它包含纯文本或span,则会有所不同。
TextView textView1;
textView1.setText("BlahBlahBlah");
TextView textView2;
final SpannableStringBuilder sb = new SpannableStringBuilder(title);
final ForegroundColorSpan fcs = new ForegroundColorSpan(Color.rgb(255,255,255));
sb.setSpan(fcs, bookname.length(),title.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
textView2.setText(sb);现在我需要这样一种方法:textView1.hasSpans()
发布于 2015-03-29 06:15:05
使用instanceOf
final CharSequence text = textView.getText();
if(text instanceof Spannable){
...我在setFilter中使用它,所以没有理由不能在这里工作
https://stackoverflow.com/questions/29326041
复制相似问题