views:

115

answers:

1

Hello I'm trying to move a circle inside a custom component, and it only moves when I click a button outside of the custom component. I touch and drag the circle, it does nothing, but as soon as I click on the button (that has nothing to do with the custom component) it gets updated (drawn) to the location where I stopped touching... Should I be calling some draw update thing on the custom component? I have Override the onTouchEvent and, among others, the onDraw. The onTouch checks for DOWN, MOVE (updates circle position) and UP just updates the beingDragged boolean. The onDraw draws a circle at the position captured on the MOVE event.. What am I missing?? Thanks!

A: 

After you change your circle's position, call invalidate(Rect)

This will force the view to redraw that section of the view.

Make sure the Rect you pass is big enough to encompass both the old position of the circle and the new location plus a few pixels worth of padding.

NOTE: Call postInvalidate() instead to do this from a non-UI thread.

CodeFusionMobile
thank you very much!!! :)
Luis