Skip to content Skip to sidebar Skip to footer

Android Multithreading With Textwatcher

I'm fairly new to Android development and am currently working on an app that allows people to type text into a box and the text is displayed on a Bitmap on screen. I have a text b

Solution 1:

You can use AsyncTask to do things in the background

publicvoid afterTextChanged(final Editable editable) {
    new AsyncTask<Void, Void, Void>() {
        protectedVoid doInBackground(Void... params) {
            pic.setText(editable.toString());
            pic.writeText();
            returnnull;
        }
        protectedvoid 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.

Post a Comment for "Android Multithreading With Textwatcher"