I am having a problem with the EditText
.
I have implemented a TextWatcher
and I check every time in afterTextChanged
to highlight some specific keywords in an AsyncTask
and set the text in onPostExcute
(I only touch the UI here), but the soft keyboard freeze when setText
was called in onPostExcute
(the app didn't freeze).
public class AsyncHighLight extends AsyncTask<String,String,String>
{
@Override
protected String doInBackground(String[] p1){
return SyntaxHighlighter.getInstance(MainActivity.this).highlight(p1[0]);
}
@Override
protected void onPostExecute(String result){
et.setText(Html.fromHtml(result));
}
}
The highlight code here
public String highlight(String s){
String newString = s;
newString = newString.replace("\n","<br>");
for (int i = 0 ; i < currentLang.keyword.length ; i ++){
newString = newString.replace(currentLang.keyword[i],warpColorTag(currentLang.keyword[i]));
}
return newString;
}