Code:
Package COM. nanguabing. splashactivity; import android. annotation. suppresslint; import android. app. activity; import android. OS. bundle; import android. OS. handler; import android. OS. message; import android. widget. imageview; @ suppresslint ("handlerleak") public class splashactivity extends activity {imageview miv01, miv02, miv03, miv04, miv05; thread mthread; Boolean misend = false; // asynchronous processing of private handler mhand in sub-threads Ler = new handler () {public void handlemessage (Message MSG) {super. handlemessage (MSG); updateui (MSG. what) ;}}; private void updateui (INT what) {If (what = 0) {miv05.setbackgroundresource (R. drawable. initdot1); miv04.setbackgroundresource (R. drawable. initdot1); miv01.setbackgroundresource (R. drawable. initdot3);} else if (what = 1) {miv01.setbackgroundresource (R. drawable. initdot3);} else if (what = 2) {m Iv01.setbackgroundresource (R. drawable. initdot2); miv02.setbackgroundresource (R. drawable. initdot3);} else if (what = 3) {miv01.setbackgroundresource (R. drawable. initdot1); miv02.setbackgroundresource (R. drawable. initdot2); miv03.setbackgroundresource (R. drawable. initdot3);} else if (what = 4) {miv02.setbackgroundresource (R. drawable. initdot1); miv03.setbackgroundresource (R. drawable. initdot2); miv04.setbac Kgroundresource (R. drawable. initdot3);} else if (what = 5) {miv03.setbackgroundresource (R. drawable. initdot1); miv04.setbackgroundresource (R. drawable. initdot2); miv05.setbackgroundresource (R. drawable. initdot3);} else if (what = 6) {miv04.setbackgroundresource (R. drawable. initdot1); miv05.setbackgroundresource (R. drawable. initdot2) ;}}@ overrideprotected void oncreate (bundle savedinstancestate) {// todo Uto-generated method stubsuper. oncreate (savedinstancestate); Init ();} private void Init () {initui (); initdata ();} public void initui () {setcontentview (R. layout. activity_splash); miv01 = (imageview) findviewbyid (R. id. s_iv01); miv02 = (imageview) findviewbyid (R. id. s_iv02); miv03 = (imageview) findviewbyid (R. id. s_iv03); miv04 = (imageview) findviewbyid (R. id. s_iv04); miv05 = (imageview) findviewbyid (R. id. s_iv05 ); Mthread = new thread (New runnable () {@ overridepublic void run () {While (! Misend) {for (INT I = 0; I <6; I ++) {system. out. println ("1111111111111111111111111111111111111111"); try {thread. sleep (500);} catch (interruptedexception e) {// todo auto-generated catch blocke. printstacktrace ();} message m = new message (); M. what = I; mhandler. sendmessage (m) ;}}}); mthread. start ();} public void initdata () {// todo auto-generated method stub} @ overridepublic void onbackpressed () {misend = true; super. onbackpressed ();}}
Csdn: Download