views:

400

answers:

1

For Android, I have a custom view which I fill up with primitive shapes in the onDraw() method.

Coming from a Processing background, I expected the draw method to be called automatically 30 times per second, but its clear that that's not how android views work.

So how should I go about calling this method 30 times per second?

+1  A: 

See this tutorial for a brief introduction. In short: Use an Animation, and call startAnimation() on it from your View.

I don't know that you can set a target framerate -- rather, you're expected to set start and end points in time, and be able to interpolate for any point in time between the two.

If you don't like this approach, you might consider having another thread which periodically calls view.postInvalidate() to request that your View be redrawn.

Charles Duffy