android - How to replace the particular word with changing text color in edittext -


string text="android operating system mobile. android latest version kitkat."; 

i have 2 edittext. first edittext used search text. second edittext used display text.

if entered android in first edittext search string text , display result in second edittext. mu question how replace android text changing color of android text only.
eg:android(red color) operating system mobile. android(red color) latest version kitkat.

i tried string ss=text.replaceall(android font color=\"red\" + android + "/font
code.
edtresult.settext(html.fromhtml(ss).
html removes spaces

thanks in advance

you can try spannable this:

edittext et = (edittext) findviewbyid(r.id.edit_text);         spannablestring ss = new spannablestring("android operating system mobile. android latest version kitkat.");         string texttosearch = "android";         pattern pattern = pattern.compile(texttosearch);         matcher matcher = pattern.matcher(ss);         while (matcher.find()) {             ss.setspan(new foregroundcolorspan(color.red), matcher.start(), matcher.end(), spanned.span_exclusive_exclusive);         } et.settext(ss); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -