Example create thread in Android with Handler and Runnable


In case you need example how to create thread in Android using Runnable & Handler() :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
final Handler h = new Handler();

new Thread(new Runnable() {
    public void run() {
        final Bitmap picture = getImageBitmap(imageURL);
        h.post(
            new Runnable() {
                public void run() {
                    listAdapter.setitem_image(position, picture);
                    progress.setProgress(position);
                }
            }  
        );
    }
}).start();

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.