当前位置: 首页>>代码示例>>Java>>正文


Java SpannableStringBuilder.toString方法代码示例

本文整理汇总了Java中android.text.SpannableStringBuilder.toString方法的典型用法代码示例。如果您正苦于以下问题:Java SpannableStringBuilder.toString方法的具体用法?Java SpannableStringBuilder.toString怎么用?Java SpannableStringBuilder.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.text.SpannableStringBuilder的用法示例。


在下文中一共展示了SpannableStringBuilder.toString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: OrgSpannable

import android.text.SpannableStringBuilder; //导入方法依赖的package包/类
public OrgSpannable(String str) {
    SpannableStringBuilder ssb = OrgFormatter.INSTANCE.parse(context, str);

    string = ssb.toString();

    Object[] allSpans = ssb.getSpans(0, ssb.length() - 1, Object.class);

    spans = new OrgSpan[allSpans.length];

    for (int i = 0; i < allSpans.length; i++) {
        spans[i] = new OrgSpan();

        spans[i].start = ssb.getSpanStart(allSpans[i]);
        spans[i].end = ssb.getSpanEnd(allSpans[i]);
        spans[i].className = allSpans[i].getClass().getSimpleName();

        if (allSpans[i] instanceof URLSpan) {
            spans[i].url = ((URLSpan)allSpans[i]).getURL();
        }
    }
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:22,代码来源:OrgFormatterTest.java

示例2: getTextWithPasswords

import android.text.SpannableStringBuilder; //导入方法依赖的package包/类
private static String getTextWithPasswords(CharSequence seq) {
    SpannableStringBuilder lstr = new SpannableStringBuilder(seq);
    for (PasswordSpan span : lstr.getSpans(0, lstr.length(), PasswordSpan.class)) {
        lstr.replace(lstr.getSpanStart(span), lstr.getSpanEnd(span), span.mPassword);
        lstr.removeSpan(span);
    }
    return lstr.toString();
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:9,代码来源:AutoRunCommandListEditText.java

示例3: renderItemNumber

import android.text.SpannableStringBuilder; //导入方法依赖的package包/类
public static void renderItemNumber(SpannableStringBuilder builder) {
    String string = builder.toString();
    if (!string.contains("、")
            || !isNumeric(string.substring(0, string.indexOf("、")))) {
        return;
    }
    ForegroundColorSpan numSpan = new ForegroundColorSpan(Color.BLUE);
    builder.setSpan(numSpan, 0, string.indexOf("、"),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
 
开发者ID:hh-in-zhuzhou,项目名称:ShangHanLun,代码行数:11,代码来源:Helper.java

示例4: addEmojis

import android.text.SpannableStringBuilder; //导入方法依赖的package包/类
/**
   * Convert emoji characters of the given Spannable to the according emojicon.
   *
   * @param context
   * @param text
   * @param emojiSize
   * @param index
   * @param length
   * @param useSystemDefault
   */
  public static SpannableStringBuilder addEmojis(Context context, SpannableStringBuilder text, int emojiSize, int textSize, int index, int length, boolean useSystemDefault) {
      if (useSystemDefault) {
          return text;
      }

      int textLengthToProcess = calculateLegalTextLength(text, index, length);

      // remove spans throughout all text
      EmojiconSpan[] oldSpans = text.getSpans(0, text.length(), EmojiconSpan.class);
      for (int i = 0; i < oldSpans.length; i++) {
          text.removeSpan(oldSpans[i]);
      }

      int[] results = new int[3];
      String textStr = text.toString();

      int processIdx = index;
      while (processIdx < textLengthToProcess) {

          boolean isEmoji = findEmoji(textStr, processIdx, textLengthToProcess, results);
          int skip = results[1];
          if (isEmoji) {
              int icon = results[0];
              boolean isQQFace = results[2] > 0;
          	EmojiconSpan span = new EmojiconSpan(context, icon, (int)(emojiSize * EMOJIICON_SCALE),
                      (int)(emojiSize * EMOJIICON_SCALE));
              span.setTranslateY(isQQFace ? QQFACE_TRANSLATE_Y : EMOJIICON_TRANSLATE_Y);
          	if (span.getCachedDrawable() == null) {
          		text.replace(processIdx, processIdx + skip,  "..");
          		//重新计算字符串的合法长度
          		textLengthToProcess = calculateLegalTextLength(text, index, length);
		} else {
			text.setSpan(span, processIdx, processIdx + skip, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
		}
          }
          
          processIdx += skip;
}
      return (SpannableStringBuilder) text.subSequence(index, processIdx);
  }
 
开发者ID:coopese,项目名称:qmui,代码行数:51,代码来源:EmojiconHandler.java

示例5: addEmojis

import android.text.SpannableStringBuilder; //导入方法依赖的package包/类
/**
 * Convert emoji characters of the given Spannable to the according emojicon.
 *
 * @param context
 * @param text
 * @param emojiSize
 * @param index
 * @param length
 * @param useSystemDefault
 */
public static SpannableStringBuilder addEmojis(Context context, SpannableStringBuilder text, int emojiSize, int textSize, int index, int length, boolean useSystemDefault) {
    if (useSystemDefault) {
        return text;
    }

    int textLengthToProcess = calculateLegalTextLength(text, index, length);

    // remove spans throughout all text
    EmojiconSpan[] oldSpans = text.getSpans(0, text.length(), EmojiconSpan.class);
    for (EmojiconSpan oldSpan : oldSpans) {
        text.removeSpan(oldSpan);
    }

    int[] results = new int[3];
    String textStr = text.toString();

    int processIdx = index;
    while (processIdx < textLengthToProcess) {

        boolean isEmoji = findEmoji(textStr, processIdx, textLengthToProcess, results);
        int skip = results[1];
        if (isEmoji) {
            int icon = results[0];
            boolean isQQFace = results[2] > 0;
            EmojiconSpan span = new EmojiconSpan(context, icon, (int) (emojiSize * EMOJIICON_SCALE),
                    (int) (emojiSize * EMOJIICON_SCALE));
            span.setTranslateY(isQQFace ? QQFACE_TRANSLATE_Y : EMOJIICON_TRANSLATE_Y);
            if (span.getCachedDrawable() == null) {
                text.replace(processIdx, processIdx + skip, "..");
                //重新计算字符串的合法长度
                textLengthToProcess = calculateLegalTextLength(text, index, length);
            } else {
                text.setSpan(span, processIdx, processIdx + skip, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }

        processIdx += skip;
    }
    return (SpannableStringBuilder) text.subSequence(index, processIdx);
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:51,代码来源:EmojiconHandler.java


注:本文中的android.text.SpannableStringBuilder.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。