List of usage examples for android.widget TextView setText
public final void setText(@StringRes int resid, BufferType type)
From source file:Main.java
public static void makeTextViewHyperlink(TextView tv) { SpannableStringBuilder ssb = new SpannableStringBuilder(); ssb.append(tv.getText());/*w w w . ja v a 2 s . c om*/ ssb.setSpan(new URLSpan("#"), 0, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); tv.setText(ssb, TextView.BufferType.SPANNABLE); }
From source file:Main.java
public static void SpannableforStrUtil(Context mContext, String spannableString, TextView textView, int style, int index) { SpannableString styledText1 = new SpannableString(spannableString); styledText1.setSpan(new TextAppearanceSpan(mContext, style), index, index + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(styledText1, TextView.BufferType.SPANNABLE); }
From source file:Main.java
public static void setTextViewCharHilighted(TextView textView, String text, int startIndex, int endIndex, int color) { if (textView == null || text == null) { return;//ww w. j av a 2s. c o m } if (startIndex < 0) { return; } if (endIndex > text.length()) { return; } textView.setText(text, BufferType.SPANNABLE); Spannable span = (Spannable) textView.getText(); if (span == null) { return; } span.setSpan(new ForegroundColorSpan(color), startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); }
From source file:com.nextgis.maplibui.util.ControlHelper.java
public static void highlightText(TextView textView) { final CharSequence text = textView.getText(); final SpannableString spannableString = new SpannableString(text); spannableString.setSpan(new URLSpan(""), 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(spannableString, TextView.BufferType.SPANNABLE); }
From source file:com.microsoft.azure.engagement.ProductDiscountActivity.java
/** * Method that adds or removes a strike from a TextView object * * @param textView The textView to manage *//*from w w w .j a va 2 s . co m*/ private final void addOrRemoveStrikeTextView(TextView textView, boolean toAdd) { textView.setText(textView.getText().toString(), TextView.BufferType.SPANNABLE); final Spannable spannable = (Spannable) textView.getText(); if (toAdd == true) { // Add a StrikethroughSpan style final StrikethroughSpan strikethroughSpan = new StrikethroughSpan(); spannable.setSpan(strikethroughSpan, 0, textView.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } else { // Remove only StrikethroughSpan style final Object spans[] = spannable.getSpans(0, textView.length(), Object.class); for (final Object span : spans) { if (span instanceof StrikethroughSpan == true) { spannable.removeSpan(span); return; } } } }