I have implemented SearchView
Widget in my app. Its working fine. Now i need to do is, whenever i type a word in my SearchView Bar
You can use this to highlight all the keywords.
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String ett = edittext.getText().toString();
String tvt = textview.getText().toString();
int ofe = tvt.indexOf(ett, 0);
Spannable spannable = new SpannableString(tvt);
for (int ofs = 0; ofs < tvt.length() && ofe != -1; ofs = ofe + 1) {
ofe = tvt.indexOf(ett, ofs);
if (ofe == -1)
break;
else {
ColorStateList blueColor = new ColorStateList(new nt[][] { new int[] {} }, new int[] { Color.BLUE });
TextAppearanceSpan highlightSpan = new TextAppearanceSpan(null, Typeface.BOLD, -1, blueColor, null);
spannable.setSpan(highlightSpan, ofe, ofe+edittext.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textview.setText(spannable);
}
}
}
});