You can use AsyncTask
to do things in the background
public void afterTextChanged(final Editable editable) {
new AsyncTask<Void, Void, Void>() {
protected Void doInBackground(Void... params) {
pic.setText(editable.toString());
pic.writeText();
return null;
}
protected void onPostExecute(Void result) {
imageView.setImageBitmap(pic.getImage());
}
}.execute();
}
You have to remember that now pic.setText(editable.toString());pic.writeText();
may be called simultaneously multiple times if the user typing fast and writetext is slow.