The Timer works fine. The problem is that the method _dw.newgame() just get executed(if two seconds are over) if i touch the display. Maybe it have sth to do with the “OnTouchListener” ?
public class DrawView extends View implements OnTouchListener{
Timer timer = new Timer();
public DrawView(Context context)
{
timer.schedule(new Task(this),0, 2000);
}
public boolean onTouch(View view, MotionEvent event)
{}
}
class Task extends TimerTask
{
private DrawView _dw;
public Task(DrawView dw){ this._dw = dw;}
public void run()
{ _dw.newgame(); }
}
Maybe you should start the timer in the
onCreatemethod:second try with handler:
I did not compile this but it should work like this.
I noticed another thing: I suppose newgame() should only be called once.
does that every 2 secs.