Adding animation to a button in BlackBerry -



Adding animation to a button in BlackBerry -

i want utilize animation on button created in blackberry app. animation works fine first time when click button. on first click, button starts animation (blinking). on sec click blinking stops. however, when click button 1 time again (third time), blinking should start again. however, error:

app error 104 uncaught: illegalstateexception

the code creating button , adding animation follows:

class="lang-java prettyprint-override"> final bitmap image000 = bitmap.getbitmapresource("panic.png"); final bitmap image001 = bitmap.getbitmapresource("panicon.png"); final timer animationtimer = new timer(); final bitmapfield animationfield = new bitmapfield(image000,bitmapfield.focusable){ protected boolean navigationclick(int status, int time) { if(flag){ animationtask.cancel(); flag=false; }else{ animationtimer.scheduleatfixedrate(animationtask, 0, 100); flag=true; } homecoming true; } }; animationtask = new timertask() { public void run() { if(counter == 0){ animationfield.setbitmap(image000); } if(counter == 1){ animationfield.setbitmap(image001); counter = -1; } counter++; } }; add(animationfield);

edit: debugged code , error occurs in loop starts thread. cancelling thread seems fine. lost issue. please guide.

try -

timertask animationtask; bitmapfield animationfield; final bitmap image000 = bitmap.getbitmapresource("panic.png"); final bitmap image001 = bitmap.getbitmapresource("panicon.png"); final timer animationtimer = new timer(); animationfield = new bitmapfield(image000,bitmapfield.focusable){ protected boolean navigationclick(int status, int time) { if(flag){ animationtask.cancel(); flag=false; }else{ animationtask = new timertask() { public void run() { if(counter == 0){ animationfield.setbitmap(image000); } if(counter == 1){ animationfield.setbitmap(image001); counter = -1; } counter++; } }; animationtask.run(); animationtimer.scheduleatfixedrate(animationtask, 0, 100); flag=true; } homecoming true; } }; animationtask = new timertask() { public void run() { if(counter == 0){ animationfield.setbitmap(image000); } if(counter == 1){ animationfield.setbitmap(image001); counter = -1; } counter++; } }; add(animationfield);

animation button blackberry imagebutton

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -