Android String Sub String Get hightLinghtString(String destStr, String subStr, int color)

Here you can find the source of hightLinghtString(String destStr, String subStr, int color)

Description

hight Linght String

Declaration

public static SpannableStringBuilder hightLinghtString(String destStr,
            String subStr, int color) 

Method Source Code

//package com.java2s;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;

public class Main {
    public static SpannableStringBuilder hightLinghtString(String destStr,
            String subStr, int color) {
        SpannableStringBuilder style = new SpannableStringBuilder(
                null == destStr ? "" : destStr);
        if (null == destStr || "".equals(destStr) || "".equals(subStr)) {
            return style;
        }//from   w ww.j  av  a 2 s.  c o m
        int start = destStr.lastIndexOf(subStr);
        if (start != -1) {
            style.setSpan(new ForegroundColorSpan(color), start, start
                    + subStr.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        }
        return style;
    }
}

Related

  1. unicodePreservingSubstring(String str, int begin, int end)
  2. unicodePreservingSubstring(String str, int begin)
  3. substringAfter(String str, String separator)
  4. substringBetween(String str, String open, String close)
  5. subStringEndString(String sourceStr, String endString)
  6. replace(String source, String subject, String object)
  7. replaceOnce(String source, String subject, String object)
  8. substring(String str, int toCount)
  9. substring(String str, int len, String more)