Android从SpannableString中删除Span

时间:2016-11-01 13:03:02

标签: java android spannablestring spannable

我的目标是从SpannableString中删除最后一个跨度。我已经像这样创建了SpannableString:

String simple = (String) label.getText();
String colored = " * ";
SpannableStringBuilder builder = new SpannableStringBuilder();

builder.append(simple);
int start = builder.length();
builder.append(colored);
int end = builder.length();

builder.setSpan(new ForegroundColorSpan(
        getResources().getColor(R.color.red)), start, end,
        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

label.setText(builder);

如何删除该结束范围?

0 个答案:

没有答案