Skip to content

Instantly share code, notes, and snippets.

@jacksonfdam
Created March 20, 2014 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacksonfdam/9655045 to your computer and use it in GitHub Desktop.
Save jacksonfdam/9655045 to your computer and use it in GitHub Desktop.
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