本文整理了Java中android.text.SpannableString.getSpanFlags()
方法的一些代码示例,展示了SpannableString.getSpanFlags()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SpannableString.getSpanFlags()
方法的具体详情如下:
包路径:android.text.SpannableString
类名称:SpannableString
方法名:getSpanFlags
暂无
代码示例来源:origin: stackoverflow.com
public class RichTextUtils {
public static <A extends CharacterStyle, B extends CharacterStyle> Spannable replaceAll(Spanned original,
Class<A> sourceType,
SpanConverter<A, B> converter) {
SpannableString result=new SpannableString(original);
A[] spans=result.getSpans(0, result.length(), sourceType);
for (A span : spans) {
int start=result.getSpanStart(span);
int end=result.getSpanEnd(span);
int flags=result.getSpanFlags(span);
result.removeSpan(span);
result.setSpan(converter.convert(span), start, end, flags);
}
return(result);
}
public interface SpanConverter<A extends CharacterStyle, B extends CharacterStyle> {
B convert(A span);
}
}
代码示例来源:origin: lovejjfg/PowerText
protected void buildPreSpans(SpannableStringBuilder mOriginBuilder) {
if (mOriginalText instanceof SpannableString) {
Object[] spans = ((SpannableString) mOriginalText).getSpans(0, mOriginalText.length(), Object.class);
if (spans.length > 0) {
for (Object span : spans) {
try {
int spanStart = ((SpannableString) mOriginalText).getSpanStart(span);
int spanEnd = ((SpannableString) mOriginalText).getSpanEnd(span);
int spanFlags = ((SpannableString) mOriginalText).getSpanFlags(span);
mOriginBuilder.setSpan(span, spanStart + labelLength, spanEnd + labelLength, spanFlags);
} catch (Exception e) {
//ignore
}
}
}
}
}
代码示例来源:origin: MCMrARM/revolution-irc
private CharSequence prepareFormat(Spannable s) {
SpannableString ret = new SpannableString(s.toString());
for (Object span : s.getSpans(0, s.length(), CharacterStyle.class)) {
if ((ret.getSpanFlags(span) & Spannable.SPAN_COMPOSING) != 0)
continue;
ret.setSpan(span, s.getSpanStart(span), s.getSpanEnd(span), s.getSpanFlags(span) & Spanned.SPAN_PRIORITY);
}
return ret;
}
代码示例来源:origin: stackoverflow.com
public static Spannable createClickableSpans(Spanned original, ClickSpan.OnClickListener listener) {
SpannableString result = new SpannableString(original);
URLSpan[] spans = result.getSpans(0, result.length(), URLSpan.class);
for (URLSpan span : spans) {
int start = result.getSpanStart(span);
int end = result.getSpanEnd(span);
int flags = result.getSpanFlags(span);
result.removeSpan(span);
result.setSpan(new ClickSpan(span.getURL(), listener), start, end, flags);
}
return result;
}
代码示例来源:origin: stackoverflow.com
private CharSequence fixSpanColor(CharSequence text) {
if (text instanceof Spanned) {
final SpannableString s = new SpannableString(text);
final ForegroundColorSpan[] spans = s.getSpans(0, s.length(), ForegroundColorSpan.class);
for (final ForegroundColorSpan oldSpan : spans) {
final ForegroundColorSpan newSpan = new ForegroundColorSpan(oldSpan.getForegroundColor() | 0xFF000000);
s.setSpan(newSpan, s.getSpanStart(oldSpan), s.getSpanEnd(oldSpan), s.getSpanFlags(oldSpan));
s.removeSpan(oldSpan);
}
return s;
} else {
return text;
}
}
代码示例来源:origin: ShonLin/QuickDevFramework
private static CharSequence fixSpanColor(CharSequence text) {
if (text instanceof Spanned) {
final SpannableString s = new SpannableString(text);
final ForegroundColorSpan[] spans = s.getSpans(0, s.length(), ForegroundColorSpan.class);
for (final ForegroundColorSpan oldSpan : spans) {
final ForegroundColorSpan newSpan = new ForegroundColorSpan(oldSpan.getForegroundColor() | 0xFF000000);
s.setSpan(newSpan, s.getSpanStart(oldSpan), s.getSpanEnd(oldSpan), s.getSpanFlags(oldSpan));
s.removeSpan(oldSpan);
}
return s;
} else {
return text;
}
}
}
代码示例来源:origin: YeDaxia/Android-YRichEditor
public static <A extends CharacterStyle, B extends CharacterStyle> Spannable replaceAll(Spanned original,
Class<A> sourceType, SpanConverter<A, B> converter) {
SpannableString result=new SpannableString(original);
A[] spans=result.getSpans(0, result.length(), sourceType);
for (A span : spans) {
int start=result.getSpanStart(span);
int end=result.getSpanEnd(span);
int flags=result.getSpanFlags(span);
result.removeSpan(span);
result.setSpan(converter.convert(span), start, end, flags);
}
return(result);
}
代码示例来源:origin: crvv/android_wubi_input
committedWordWithSuggestionSpans.getSpanFlags(span));
内容来源于网络,如有侵权,请联系作者删除!