Created
March 20, 2014 00:50
-
-
Save jacksonfdam/9655045 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Clica(View v) { | |
final ImageView iv = (ImageView) findViewById(R.id.imageView1); | |
new Thread(new Runnable() { | |
public void run() { | |
final Bitmap imgAux = | |
loadImageFromNetwork("http://targettrust.com.br/img/header-logo_v2.png"); | |
iv.setImageBitmap(imgAux); | |
handler.post(new Runnable() { | |
public void run() { | |
iv.setImageBitmap(imgAux); | |
} | |
}); | |
} | |
}).start(); | |
} | |
public Bitmap loadImageFromNetwork(String urlImg) { | |
Bitmap img = null; | |
try { | |
Thread.sleep(1000); | |
} catch (InterruptedException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
try { | |
URL url = new URL(urlImg); | |
HttpURLConnection conexao = (HttpURLConnection) url | |
.openConnection(); | |
InputStream input = conexao.getInputStream(); | |
img = BitmapFactory.decodeStream(input); | |
} catch (IOException e) { | |
} | |
return img; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment