i want make simple game, 1 image view , 2 buttons guess if card red of black.
i want use thread, every 0.1 seconds before player presses button, card changing.
this used far :
thread timer = new thread() { public void run() { while (true) { try { if(!isinterrupted()) sleep(100); else sleep(5000); runonuithread(new runnable() { @override public void run() { if(!isinterrupted()) { if (iv_card_to_guess.getdrawable() == null) iv_card_to_guess.setimagebitmap(deck_card); else iv_card_to_guess.setimagedrawable(null); } else { //here need update imageview actual image of card, not deck or null // example 5 of hearts loadbitmap(getresourceid("img_" + numbers.get(count).tostring(), "drawable", getapplicationcontext()), iv_card_to_guess); } } }); } catch (interruptedexception e) { e.printstacktrace(); } } } }; when press button call timer.interrupt();
the application changes image of actual card 0.1 seconds, not 5 seconds, want :)
how can this, please?
private timer timer; timertask task = new timertask() { @override public void run() { // todo auto-generated method stub insert code want trigger here. } }; timer = new timer(); int delay=5000; timer.schedule(task, delay);
Comments
Post a Comment