Android Runnable not working on android 2.3? -
i have following code:
btn.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { if (event.getaction() == motionevent.action_down) { v.post(pressed); // put runnable 'pressed' in // asynchrone message queue } return false; } }); private runnable pressed = new runnable() { @override public void run() { if (btn.ispressed()) { sky.draweverything(); btn.postdelayed(pressed, 10); } } };
this works charm android 4.1.2, if try on android 2.3 runnable seems stay untriggered. i'm using api 1 or above, why doesn't work?
what alternative way of archieving same result , making work on older android versions?
he not sure :) code works on 4+ , in 2.3.6 tested having issues line if(btn.ispressed()), reason doesn't return true. here working hack, on samsung galaxy s 2.3.6
btn.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { if (event.getaction() == motionevent.action_down) { v.setpressed(true); v.post(pressed); // put runnable 'pressed' in // asynchrone message queue } if(event.getaction() == motionevent.action_up){ v.setpressed(false); } return false; } }); } private runnable pressed = new runnable() { @override public void run() { if (btn.ispressed()) { //sky.draweverything(); btn.postdelayed(pressed, 10); } else { //print or whatever } } };
hope helps , enjoy work.
Comments
Post a Comment