在Android中,可以使用以下方法來(lái)格式化CharSequence:
CharSequence str = "Hello";
String formattedStr = String.format("Formatted string: %s", str);
CharSequence str = "World";
StringBuilder builder = new StringBuilder();
builder.append("Formatted string: ");
builder.append(str);
String formattedStr = builder.toString();
CharSequence str = "Android";
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append("Formatted string: ");
SpannableString spannableStr = new SpannableString(str);
spannableStr.setSpan(new ForegroundColorSpan(Color.RED), 0, str.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.append(spannableStr);
CharSequence formattedStr = builder;