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


Java SpannableStringBuilder类代码示例

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


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

示例1: internalUpdate

import android.text.SpannableStringBuilder; //导入依赖的package包/类
@Override
protected void internalUpdate(XySeriesInfo seriesInfo) {
    final SpannableStringBuilder sb = new SpannableStringBuilder();

    sb.append("X: ").append(seriesInfo.getFormattedXValue()).append(StringUtil.NEW_LINE);
    sb.append("Y: ").append(seriesInfo.getFormattedYValue()).append(StringUtil.NEW_LINE);

    if (seriesInfo.seriesName != null) {
        final int start = sb.length();

        sb.append(seriesInfo.seriesName);
        sb.setSpan(new ForegroundColorSpan(ColorUtil.White), start, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        sb.append(StringUtil.NEW_LINE);
    }
    sb.append(modifierName);
    setText(sb);

    // stroke 0xff4d81dd
    setSeriesColor(0xff6495ed);
}
 
开发者ID:ABTSoftware,项目名称:SciChart.Android.Examples,代码行数:21,代码来源:CustomTooltipsWithModifiersFragment.java

示例2: getMessagePreview

import android.text.SpannableStringBuilder; //导入依赖的package包/类
private CharSequence getMessagePreview(LocalMessage message) {
    String subject = message.getSubject();
    String snippet = getPreview(message);

    boolean isSubjectEmpty = TextUtils.isEmpty(subject);
    boolean isSnippetPresent = snippet != null;
    if (isSubjectEmpty && isSnippetPresent) {
        return snippet;
    }

    String displaySubject = getMessageSubject(message);

    SpannableStringBuilder preview = new SpannableStringBuilder();
    preview.append(displaySubject);
    if (isSnippetPresent) {
        preview.append('\n');
        preview.append(snippet);
    }
    
    return preview;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:22,代码来源:NotificationContentCreator.java

示例3: MongolTextView

import android.text.SpannableStringBuilder; //导入依赖的package包/类
public MongolTextView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MongolTextView, defStyleAttr, 0);

    boolean isEditText = getDefaultEditable();
    String text = a.getString(R.styleable.MongolTextView_text);
    if (text == null) text = "";
    if (isEditText) {
        SpannableStringBuilder ssb = new SpannableStringBuilder(text);
        mTextStorage = new MongolTextStorage(ssb);
    } else {
        mTextStorage = new MongolTextStorage(text);
    }
    mTextSizePx = a.getDimensionPixelSize(R.styleable.MongolTextView_textSize, 0);
    mTextColor = a.getColor(R.styleable.MongolTextView_textColor, Color.BLACK);
    mGravity = a.getInteger(R.styleable.MongolTextView_gravity, Gravity.TOP);
    a.recycle();

    mContext = context;
    init();
}
 
开发者ID:suragch,项目名称:mongol-library,代码行数:23,代码来源:MongolTextView.java

示例4: setPrimaryMessageBody

import android.text.SpannableStringBuilder; //导入依赖的package包/类
public void setPrimaryMessageBody(@NonNull  Recipients threadRecipients,
                                  @NonNull  Recipient individualRecipient,
                                  @NonNull  CharSequence message,
                                  @Nullable SlideDeck slideDeck)
{
  SpannableStringBuilder stringBuilder = new SpannableStringBuilder();

  if (privacy.isDisplayContact() && (threadRecipients.isGroupRecipient() || !threadRecipients.isSingleRecipient())) {
    stringBuilder.append(Util.getBoldedString(individualRecipient.toShortString() + ": "));
  }

  if (privacy.isDisplayMessage()) {
    setContentText(stringBuilder.append(message));
    this.slideDeck = slideDeck;
  } else {
    setContentText(stringBuilder.append(context.getString(R.string.SingleRecipientNotificationBuilder_new_message)));
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:19,代码来源:SingleRecipientNotificationBuilder.java

示例5: handleTagNode

import android.text.SpannableStringBuilder; //导入依赖的package包/类
@Override
public void handleTagNode(TagNode node, SpannableStringBuilder builder,
		int start, int end, SpanStack stack) {
	String src = node.getAttributeByName("src");

	builder.append("\uFFFC");

	Bitmap bitmap = loadBitmap(src);

	if (bitmap != null) {
		Drawable drawable = new BitmapDrawable(bitmap);
		drawable.setBounds(0, 0, bitmap.getWidth() - 1,
				bitmap.getHeight() - 1);

           stack.pushSpan( new ImageSpan(drawable), start, builder.length() );
	}
}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:18,代码来源:ImageHandler.java

示例6: setView

import android.text.SpannableStringBuilder; //导入依赖的package包/类
public void setView(Context mContext, final View view, String content) {
    if (view != null && view instanceof ImageView) {//图片不显示GIF
        Bitmap bitmap = null;
        try {
            bitmap = BitmapFactory.decodeStream(mContext.getAssets().open(content));
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        ((ImageView) view).setImageBitmap(bitmap);
    } else if (view != null && view instanceof TextView) {//文字可显示GIF
        TextView gifTextView = (TextView) view;
        String tempText = "[" + content + "]";
        SpannableStringBuilder sb = prase(mContext, gifTextView, tempText);
        gifTextView.setText(sb);
    }

}
 
开发者ID:DyncKathline,项目名称:LiveGiftLayout,代码行数:18,代码来源:ExpressionUtil.java

示例7: getTeaser

import android.text.SpannableStringBuilder; //导入依赖的package包/类
public static SpannableStringBuilder getTeaser(Context ctx, Spanned body) {
	if (body.length() < TEASER_LENGTH)
		throw new IllegalArgumentException(
				"String is shorter than TEASER_LENGTH");

	SpannableStringBuilder builder =
			new SpannableStringBuilder(body.subSequence(0, TEASER_LENGTH));
	String ellipsis = ctx.getString(R.string.ellipsis);
	builder.append(ellipsis).append(" ");

	Spannable readMore = new SpannableString(
			ctx.getString(R.string.read_more) + ellipsis);
	ForegroundColorSpan fg = new ForegroundColorSpan(
			ContextCompat.getColor(ctx, R.color.briar_text_link));
	readMore.setSpan(fg, 0, readMore.length(),
			Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
	builder.append(readMore);

	return builder;
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:21,代码来源:UiUtils.java

示例8: patternPhone

import android.text.SpannableStringBuilder; //导入依赖的package包/类
/**
 * 匹配 电话号码
 */
protected void patternPhone(SpannableStringBuilder builder, CharSequence input) {
    Matcher matcher = patternPhone.matcher(input);

    while (matcher.find()) {
        int start = matcher.start();
        int end = matcher.end();

        if (!isInOtherSpan(builder, input.length(), start, end)) {
            builder.setSpan(new ImageTextSpan(getContext(), ImageTextSpan.initDrawable(getTextSize()),
                            matcher.group(), matcher.group())
                            .setOnImageSpanClick(mOnImageSpanClick)
                            .setTextColor(mImageSpanTextColor),
                    start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:20,代码来源:RExTextView.java

示例9: fixSpannedWithSpaces

import android.text.SpannableStringBuilder; //导入依赖的package包/类
/**
 * Add spaces around spans until the text is fixed, and then removes the unneeded spaces
 */
private void fixSpannedWithSpaces(SpannableStringBuilder builder, int widthMeasureSpec,
                                  int heightMeasureSpec) {
    long startFix = System.currentTimeMillis();

    FixingResult result = addSpacesAroundSpansUntilFixed(builder, widthMeasureSpec,
            heightMeasureSpec);

    if (result.fixed) {
        removeUnneededSpaces(widthMeasureSpec, heightMeasureSpec, builder, result);
    } else {
        fallbackToString(widthMeasureSpec, heightMeasureSpec);
    }

    if (HtmlTextView.DEBUG) {
        long fixDuration = System.currentTimeMillis() - startFix;
        Log.d(HtmlTextView.TAG, "fixSpannedWithSpaces() duration in ms: " + fixDuration);
    }
}
 
开发者ID:RanKKI,项目名称:PSNine,代码行数:22,代码来源:JellyBeanSpanFixTextView.java

示例10: setText

import android.text.SpannableStringBuilder; //导入依赖的package包/类
@Override
public void setText(CharSequence text, BufferType type) {
    if (isInEditMode()) {
        super.setText(text, type);
        return;
    }
    if (TextUtils.isEmpty(text)) {
        super.setText(text, type);
    } else {
        SpannableStringBuilder spanBuilder = new SpannableStringBuilder(text);
        if (needPatternUrl) {
            patternUrl(spanBuilder, text);//优先匹配
        }
        if (needPatternMention) {
            patternMention(spanBuilder, text);
        }
        if (needPatternPhone) {
            patternPhone(spanBuilder, text);
        }
        afterPattern(spanBuilder, text);
        super.setText(spanBuilder, type);
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:24,代码来源:RExTextView.java

示例11: onCreateView

import android.text.SpannableStringBuilder; //导入依赖的package包/类
@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
    if (mRootView != null) {
      return mRootView;
    }
    mRootView = inflater.inflate(R.layout.ellipse_demo, container, false);
    SpannableStringBuilder spannableStringBuilder = getSpannable();
    FastTextView fastTextView = (FastTextView) mRootView.findViewById(R.id.fast_tv2);
    fastTextView.setText(spannableStringBuilder);
//    fastTextView.setCustomEllipsisSpan(new ImageSpan(drawable));

    TextView tv = (TextView) mRootView.findViewById(R.id.system_tv);
    tv.setText(spannableStringBuilder);
//    tv.setMovementMethod(LinkMovementMethod.getInstance());


    return mRootView;
  }
 
开发者ID:lsjwzh,项目名称:FastTextView,代码行数:20,代码来源:EllipseFragment.java

示例12: updateView

import android.text.SpannableStringBuilder; //导入依赖的package包/类
private void updateView() {
    if (!isResumed())
        return;

    final String bitcoinRequest = determineBitcoinRequestStr(true);
    final byte[] paymentRequest = determinePaymentRequest(true);

    // update qr-code
    qrCodeBitmap = new BitmapDrawable(getResources(), Qr.bitmap(bitcoinRequest));
    qrCodeBitmap.setFilterBitmap(false);
    qrView.setImageDrawable(qrCodeBitmap);

    // update initiate request message
    final SpannableStringBuilder initiateText = new SpannableStringBuilder(
            getString(R.string.request_coins_fragment_initiate_request_qr));
    if (nfcAdapter != null && nfcAdapter.isEnabled())
        initiateText.append(' ').append(getString(R.string.request_coins_fragment_initiate_request_nfc));
    initiateRequestView.setText(initiateText);

    // focus linking
    final int activeAmountViewId = amountCalculatorLink.activeTextView().getId();
    acceptBluetoothPaymentView.setNextFocusUpId(activeAmountViewId);

    paymentRequestRef.set(paymentRequest);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:26,代码来源:RequestCoinsFragment.java

示例13: configurePinnedHeader

import android.text.SpannableStringBuilder; //导入依赖的package包/类
@Override
public void configurePinnedHeader(View headerView, int position, int alpaha) {
    // TODO Auto-generated method stub
    TextView label = (TextView) headerView.findViewById(R.id.textLabel);
    NSIndexPath ip = getIndexPath(position);
    curSection = ip.getSection();
    String t = mTableView.getDataSource().titleForHeaderInSection(
            mTableView, curSection);
    if (t != null) {
        label.setText(t);
    } else {
        SpannableStringBuilder buider = mTableView.getDataSource()
                .spannerbleTitleForHeaderInSection(mTableView, curSection);
        label.setText(buider);
    }
    // huanghai
    label.setTextColor(Color.BLACK);
    label.setGravity(Gravity.CENTER_VERTICAL);
}
 
开发者ID:hh-in-zhuzhou,项目名称:ShangHanLun,代码行数:20,代码来源:ATableViewAdapter.java

示例14: getColoredChattingRecord

import android.text.SpannableStringBuilder; //导入依赖的package包/类
public SpannableStringBuilder getColoredChattingRecord(String filterStr, MessageContent messageContent) {
    SpannableStringBuilder messageText = new SpannableStringBuilder();
    if (messageContent instanceof TextMessage) {
        TextMessage textMessage = (TextMessage) messageContent;
        String textMessageContent = textMessage.getContent();
        messageText = getOmitColored(filterStr, textMessageContent, 0);
    }
    if (messageContent instanceof RichContentMessage) {
        RichContentMessage richContentMessage = (RichContentMessage) messageContent;
        String messageTitle = richContentMessage.getTitle();
        messageText = getOmitColored(filterStr, messageTitle, 1);
        if (messageText.length() == 0) {
            SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder("[链接] ");
            spannableStringBuilder.append(messageTitle);
            messageText = spannableStringBuilder;
        }
    }
    if (messageContent instanceof FileMessage) {
        FileMessage fileMessage = (FileMessage) messageContent;
        String fileName = fileMessage.getName();
        messageText = getOmitColored(filterStr, fileName, 2);
    }
    return messageText;
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:25,代码来源:CharacterParser.java

示例15: makeThreeOrMoreItems

import android.text.SpannableStringBuilder; //导入依赖的package包/类
@NonNull
private CharSequence makeThreeOrMoreItems() {
    if (separator == null) {
        throw new LexNoSeparatorException();
    }

    SpannableStringBuilder sb = new SpannableStringBuilder(getWrappedItem(0));
    for (int i = 1; i < items.length; i++) {
        if (i == items.length - 1 && lastItemSeparator != null) {
            sb.append(lastItemSeparator);
        } else {
            sb.append(separator);
        }
        sb.append(getWrappedItem(i));
    }
    return sb;
}
 
开发者ID:halfhp,项目名称:lex,代码行数:18,代码来源:LexList.java


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