当前位置: 首页>>代码示例>>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;未经允许,请勿转载。