Search in sources :

Example 26 with SpannableString

use of android.text.SpannableString in project weiciyuan by qii.

the class TimeLineUtility method buildOriWeiboSpannalString.

private static SpannableString buildOriWeiboSpannalString(MessageBean oriMsg) {
    String name = "";
    UserBean oriUser = oriMsg.getUser();
    if (oriUser != null) {
        name = oriUser.getScreen_name();
        if (TextUtils.isEmpty(name)) {
            name = oriUser.getId();
        }
    }
    SpannableString value;
    if (!TextUtils.isEmpty(name)) {
        value = TimeLineUtility.convertNormalStringToSpannableString("@" + name + ":" + oriMsg.getText());
    } else {
        value = TimeLineUtility.convertNormalStringToSpannableString(oriMsg.getText());
    }
    return value;
}
Also used : SpannableString(android.text.SpannableString) UserBean(org.qii.weiciyuan.bean.UserBean) DMUserBean(org.qii.weiciyuan.bean.DMUserBean) SpannableString(android.text.SpannableString)

Example 27 with SpannableString

use of android.text.SpannableString in project weiciyuan by qii.

the class UpdateMessageTask method setTextViewDeleted.

private void setTextViewDeleted() {
    SpannableString ss = SpannableString.valueOf(content.getText());
    ss.setSpan(new StrikethroughSpan(), 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    content.setText(ss);
}
Also used : SpannableString(android.text.SpannableString) StrikethroughSpan(android.text.style.StrikethroughSpan)

Example 28 with SpannableString

use of android.text.SpannableString in project Libraries-for-Android-Developers by eoecn.

the class SuggestionsAdapter method formatUrl.

private CharSequence formatUrl(CharSequence url) {
    if (mUrlColor == null) {
        // Lazily get the URL color from the current theme.
        TypedValue colorValue = new TypedValue();
        mContext.getTheme().resolveAttribute(R.attr.textColorSearchUrl, colorValue, true);
        mUrlColor = mContext.getResources().getColorStateList(colorValue.resourceId);
    }
    SpannableString text = new SpannableString(url);
    text.setSpan(new TextAppearanceSpan(null, 0, 0, mUrlColor, null), 0, url.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return text;
}
Also used : SpannableString(android.text.SpannableString) TextAppearanceSpan(android.text.style.TextAppearanceSpan) TypedValue(android.util.TypedValue)

Example 29 with SpannableString

use of android.text.SpannableString in project materialistic by hidroh.

the class HelpListView method makeAsteriskSpan.

private Spannable makeAsteriskSpan() {
    SpannableString sb = new SpannableString("*");
    sb.setSpan(new AsteriskSpan(getContext()), sb.length() - 1, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return sb;
}
Also used : SpannableString(android.text.SpannableString) AsteriskSpan(io.github.hidroh.materialistic.widget.AsteriskSpan)

Example 30 with SpannableString

use of android.text.SpannableString in project zxingfragmentlib by mitoyarzun.

the class SearchBookContentsListItem method set.

public void set(SearchBookContentsResult result) {
    pageNumberView.setText(result.getPageNumber());
    String snippet = result.getSnippet();
    if (snippet.isEmpty()) {
        snippetView.setText("");
    } else {
        if (result.getValidSnippet()) {
            String lowerQuery = SearchBookContentsResult.getQuery().toLowerCase(Locale.getDefault());
            String lowerSnippet = snippet.toLowerCase(Locale.getDefault());
            Spannable styledSnippet = new SpannableString(snippet);
            StyleSpan boldSpan = new StyleSpan(Typeface.BOLD);
            int queryLength = lowerQuery.length();
            int offset = 0;
            while (true) {
                int pos = lowerSnippet.indexOf(lowerQuery, offset);
                if (pos < 0) {
                    break;
                }
                styledSnippet.setSpan(boldSpan, pos, pos + queryLength, 0);
                offset = pos + queryLength;
            }
            snippetView.setText(styledSnippet);
        } else {
            // This may be an error message, so don't try to bold the query terms within it
            snippetView.setText(snippet);
        }
    }
}
Also used : SpannableString(android.text.SpannableString) StyleSpan(android.text.style.StyleSpan) SpannableString(android.text.SpannableString) Spannable(android.text.Spannable)

Aggregations

SpannableString (android.text.SpannableString)325 TextView (android.widget.TextView)61 Spannable (android.text.Spannable)60 View (android.view.View)57 StyleSpan (android.text.style.StyleSpan)53 ForegroundColorSpan (android.text.style.ForegroundColorSpan)47 TextPaint (android.text.TextPaint)25 Spanned (android.text.Spanned)24 TextAppearanceSpan (android.text.style.TextAppearanceSpan)21 Paint (android.graphics.Paint)20 RelativeSizeSpan (android.text.style.RelativeSizeSpan)19 ImageView (android.widget.ImageView)19 Bundle (android.os.Bundle)17 TypedValue (android.util.TypedValue)17 SmallTest (android.test.suitebuilder.annotation.SmallTest)16 Intent (android.content.Intent)15 SpannableStringBuilder (android.text.SpannableStringBuilder)15 ClickableSpan (android.text.style.ClickableSpan)14 URLSpan (android.text.style.URLSpan)13 LayoutInflater (android.view.LayoutInflater)13