Created
November 27, 2016 10:53
-
-
Save pratamawijaya/9b7f4dd67933ffc6a0f030e6fc9f08aa to your computer and use it in GitHub Desktop.
TextHighlight.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// digunakan untuk Highlight text yang sedang dicari | |
private void setColor(TextView view, String fulltext, String subtext, int color) { | |
view.setText(fulltext, TextView.BufferType.SPANNABLE); | |
Spannable str = (Spannable) view.getText(); | |
int i = fulltext.indexOf(subtext); | |
str.setSpan(new ForegroundColorSpan(color), i, i + subtext.length(), | |
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment