Android Studio에서 Thread란 무엇인가?
Published on October 16, 2021 by Jieun Han
Android Studio Thread
1 min READ
public void onClick(View v) {
new Thread(new Runnable()) {
public void run() {
final Bitmap bitmap =
loadImageFromNetwork("http://example.com/image.png");
mImageView.post(new Runnable()) { //Handler
public void run() {
mImageView.setImageBitmap(b);
}
}
}
}
}
public void onClick(View v) {
new DownloadImageTask().execute("http://example.com/image.png");
}
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
protected Bitmap doInBackground(String... urls) {
return loadImageFromNetwork(urls[0]);
}
protected void onPostExecute(Bitmap result) {
mImageView.setImageBitmap(result);
}
}