Lines Matching refs:text

19 import android.text.SpannableString;
20 import android.text.style.CharacterStyle;
21 import android.text.style.StyleSpan;
24 /** Highlights the text in a text field. */
37 * Sets the text on the given text view, highlighting the word that matches the given prefix.
39 * @param view the view on which to set the text
40 * @param text the string to use as the text
43 public void setPrefixText(TextView view, String text, String prefix) {
44 view.setText(applyPrefixHighlight(text, prefix));
52 * Applies highlight span to the text.
54 * @param text Text sequence to be highlighted.
58 public void applyMaskingHighlight(SpannableString text, int start, int end) {
59 /** Sets text color of the masked locations to be highlighted. */
60 text.setSpan(getStyleSpan(), start, end, 0);
64 * Returns a CharSequence which highlights the given prefix if found in the given text.
66 * @param text the text to which to apply the highlight
69 public CharSequence applyPrefixHighlight(CharSequence text, String prefix) {
71 return text;
82 int index = indexOfWordPrefix(text, trimmedPrefix);
84 final SpannableString result = new SpannableString(text);
88 return text;
97 * @param text the text in which to search for the prefix
98 * @param prefix the text to find, in upper case letters
100 public static int indexOfWordPrefix(CharSequence text, String prefix) {
101 if (prefix == null || text == null) {
105 int textLength = text.length();
115 while (i < textLength && !Character.isLetterOrDigit(text.charAt(i))) {
126 if (Character.toUpperCase(text.charAt(i + j)) != prefix.charAt(j)) {
135 while (i < textLength && Character.isLetterOrDigit(text.charAt(i))) {