本文整理汇总了Java中android.text.NoCopySpan类的典型用法代码示例。如果您正苦于以下问题:Java NoCopySpan类的具体用法?Java NoCopySpan怎么用?Java NoCopySpan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NoCopySpan类属于android.text包,在下文中一共展示了NoCopySpan类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addHistoryMessage
import android.text.NoCopySpan; //导入依赖的package包/类
public void addHistoryMessage(CharSequence msg) {
SpannableString str = new SpannableString(msg);
for (Object o : str.getSpans(0, str.length(), NoCopySpan.class))
str.removeSpan(o);
mSentMessageHistory.add(str);
if (mSentMessageHistory.size() >= HISTORY_MAX_COUNT)
mSentMessageHistory.remove(0);
}
示例2: SpannableStringBuilder
import android.text.NoCopySpan; //导入依赖的package包/类
/**
* Create a new SpannableStringBuilder containing a copy of the
* specified slice of the specified text, including its spans if any.
*/
public SpannableStringBuilder(CharSequence text, int start, int end) {
int srclen = end - start;
int len = ArrayUtils.idealCharArraySize(srclen + 1);
mText = new char[len];
mGapStart = srclen;
mGapLength = len - srclen;
TextUtils.getChars(text, start, end, mText, 0);
mSpanCount = 0;
int alloc = ArrayUtils.idealIntArraySize(0);
mSpans = new Object[alloc];
mSpanStarts = new int[alloc];
mSpanEnds = new int[alloc];
mSpanFlags = new int[alloc];
if (text instanceof Spanned) {
Spanned sp = (Spanned) text;
Object[] spans = sp.getSpans(start, end, Object.class);
for (int i = 0; i < spans.length; i++) {
if (spans[i] instanceof NoCopySpan) {
continue;
}
int st = sp.getSpanStart(spans[i]) - start;
int en = sp.getSpanEnd(spans[i]) - start;
int fl = sp.getSpanFlags(spans[i]);
if (st < 0)
st = 0;
if (st > end - start)
st = end - start;
if (en < 0)
en = 0;
if (en > end - start)
en = end - start;
if ( st <= en ) {
setSpan(spans[i], st, en, fl);
}
}
}
}