Created
October 18, 2014 02:56
-
-
Save icarofreire/991652ccfbade9b72fc8 to your computer and use it in GitHub Desktop.
Trocar por meio de Thread, o background de uma imagem durante um evento de uma aplicação Android.
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 swap(final Activity atividade, final View v, final int R_drawable_imagem_widget_1, final int R_drawable_imagem_widget_2) | |
{ | |
v.setBackgroundResource(R_drawable_imagem_widget_1); | |
new Thread(new Runnable() | |
{ | |
public void run() | |
{ | |
try{/* \/ Para a execução por N milissegundos. */ | |
Thread.sleep(200);/* <- 200 milissegundos.*/ | |
} catch (InterruptedException e) | |
{ e.printStackTrace(); } | |
atividade.runOnUiThread(new Runnable() | |
{ | |
public void run(){ | |
v.setBackgroundResource(R_drawable_imagem_widget_2); | |
} | |
}); | |
} | |
}).start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment