當前位置: 首頁>>代碼示例>>Java>>正文


Java SpannableStringBuilder.valueOf方法代碼示例

本文整理匯總了Java中android.text.SpannableStringBuilder.valueOf方法的典型用法代碼示例。如果您正苦於以下問題:Java SpannableStringBuilder.valueOf方法的具體用法?Java SpannableStringBuilder.valueOf怎麽用?Java SpannableStringBuilder.valueOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.text.SpannableStringBuilder的用法示例。


在下文中一共展示了SpannableStringBuilder.valueOf方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: disableOnlyFullAppPrefs

import android.text.SpannableStringBuilder; //導入方法依賴的package包/類
private void disableOnlyFullAppPrefs() {
    String fullOnly = " FULL ONLY ";
    int color = Utils.adjustAlpha(CurrentTheme.getColorAccent(getActivity()), 100);

    for (String name : AppPrefs.ONLY_FULL_APP_PREFS) {
        Preference preference = findPreference(name);
        if (preference != null) {
            preference.setEnabled(false);

            CharSequence summary = TextUtils.isEmpty(preference.getTitle()) ? "" : preference.getTitle();
            summary = fullOnly + " " + summary;

            Spannable spannable = SpannableStringBuilder.valueOf(summary);

            BackgroundColorSpan span = new BackgroundColorSpan(color);
            ForegroundColorSpan span1 = new ForegroundColorSpan(Color.WHITE);

            spannable.setSpan(span, 0, fullOnly.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            spannable.setSpan(span1, 0, fullOnly.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            preference.setTitle(spannable);
        }
    }
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:24,代碼來源:PreferencesFragment.java

示例2: setText

import android.text.SpannableStringBuilder; //導入方法依賴的package包/類
@Override
public void setText(CharSequence originalText, BufferType type) {
    if (originalText != null && originalText.length() > 0) {
        Spannable spannable = SpannableStringBuilder.valueOf(originalText);

        if (mDisplayHashTags) {
            setColorsToAllHashTags(spannable);
        }

        if (!Settings.get().ui().isSystemEmoji()){
            EmojiconHandler.addEmojis(getContext(), spannable, mEmojiconSize, mTextStart, mTextLength);
        }

        super.setText(spannable, type);
    } else {
        super.setText(originalText, type);
    }
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:19,代碼來源:EmojiconTextView.java

示例3: bindTitle

import android.text.SpannableStringBuilder; //導入方法依賴的package包/類
private void bindTitle(TitleViewHolder holder) {
    if (mLayoutManager instanceof StaggeredGridLayoutManager) {
        StaggeredGridLayoutManager.LayoutParams layoutParams = new StaggeredGridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.setFullSpan(true);
        holder.itemView.setLayoutParams(layoutParams);
    }

    final int position = holder.getAdapterPosition();
    if (position == 0) {
        String title = mContext.getString(getTypeTitle());
        String fullText = mContext.getString(R.string.who_can_have_access) + " " + title;
        Spannable spannable = SpannableStringBuilder.valueOf(fullText);
        ClickableSpan span = new ClickableSpan() {
            @Override
            public void onClick(View widget) {
                if(mActionListener != null){
                    mActionListener.onTypeClick();
                }
            }
        };

        spannable.setSpan(span, fullText.length() - title.length(), fullText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        holder.title.setText(spannable, TextView.BufferType.SPANNABLE);
    } else {
        holder.title.setText(R.string.who_cannot_have_access);
    }

    holder.buttonAdd.setOnClickListener(v -> {
        if(mActionListener != null){
            if(position == 0){
                mActionListener.onAddToAllowedClick();
            } else {
                mActionListener.onAddToDisallowedClick();
            }
        }
    });
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:38,代碼來源:PrivacyAdapter.java

示例4: computeCharacterStyleRanges

import android.text.SpannableStringBuilder; //導入方法依賴的package包/類
private List<Range<Integer>> computeCharacterStyleRanges(CharSequence text) {
    final SpannableStringBuilder ssb = SpannableStringBuilder.valueOf(text);
    final CharacterStyle[] characterStyles = ssb.getSpans(0, ssb.length(), CharacterStyle.class);

    if (characterStyles == null || characterStyles.length == 0) {
        return Collections.EMPTY_LIST;
    }

    List<Range<Integer>> ranges = new ArrayList<>();
    for (CharacterStyle characterStyle : characterStyles) {
        ranges.add(new Range<>(ssb.getSpanStart(characterStyle), ssb.getSpanEnd(characterStyle)));
    }

    return ranges;
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:16,代碼來源:EllipsizeTextView.java


注:本文中的android.text.SpannableStringBuilder.valueOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。