當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。