timer - Android ViewFlipper showPrevious after 300ms -
hey. started android. i'm using viewflipper layout 2 linearlayouts. first layout has button switches second layout. add timer switch first layout after 3000ms. tried thread did not work (can not communicate ui element of other thread).
my code:
public class test extends activity {
viewflipper f; linearlayout l1; linearlayout l2; button b1; thread s; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); f = (viewflipper) findviewbyid(r.id.f); l1 = (linearlayout) findviewbyid(r.id.l1); l2 = (linearlayout) findviewbyid(r.id.l2); b1 = (button) findviewbyid(r.id.b1); updateswitch = new thread() { @override public void run() { try {sleep(3000); } catch (interruptedexception e) { } {f.showprevious();} } }; b1.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { f.setanimation(animationutils.loadanimation(v.getcontext(), r.anim.push_left_in)); lflipper.shownext(); updateswitch.start(); } }); }
}
my guess need kind of handler connect new thread main thread. please update code. thx 10x.
you need read technical article updating ui timer
Comments
Post a Comment