Smills wrote:The ball will only move when i am touching the screen for some reason (doesn't matter where I am touching). It seems the draw method is only called when there is interaction. Any idea what method i can put code in to have it called every cycle?

Hey Smills,In order for you to have to ball continusly moving all you should have to do is take it out of your onTouch method and put it else where like in a timer

Thanks for a nice tutorial. Can you help me in dragging and dropping the balls from one view to another. I have a linearlyaout that has 2 views. I want to drag and drop the balls from one view to another. Balls should only fall into place if user drags them to another view otherwise the ball should come back to its original view.

I have a very strange problem with a simple modification on the code!I wanted to have the overall control of the let's say app in the activity so first i take all the code from the DrawView.class and paste it into the activity class and delete the DrawView.class file since it didn't need!everything works fine!!!Then to seperate a little bit more the code i took all the onTouchevent code and paste it in the activity class(see the code below)!

And the strange to all this is that the onTouchevent is working(all actions up move down is being captured) but the if() statement which is checking if we are in the ball bounds doesn't!!!To be more specific it's like it can't read the X,Y vars!

When i use this(in onTouchEvent in ACTION_DOWN, the values i use here isn't the values that i was using when i was testing it i had calculate what values should i use)

So i came up that although they are two simple vars(X,Y) which i can take their values and print them i can't use them inside the if statement because the ontouchevent should always be inside a view.(i know it doesn't sound right,can't we have touch events which will be handled from the activity?)

Good night guys, I'm from Brazil and I'm trying to develop a software that has the function of dragging an image coming from a file. Xml (R.layout.main), but am not able to accomplish this task. Anyone have any examples of how to do this?Thank you very much for your help if they can collaborate.

Yes, here you explain consistently a rather direct approach. I'd call canvas oriented. The container implements onDraw() and will draw from scratch all your items into the canvas. The item being dragged obliously get drawn att it's new position.

Another approach might be interesting too. I'd call layout-oriented. Without any onDraw() implementation. It make sense when you can consider a container with a FrameLayout. Dragging a child can be carried out by just actualizing it's LayoutParams.

thanks Marchu for the tree ball code.How would you go about to modify the code to have a TextEdit moved instead of graphic (ball).Wanted to put text on a picture and then save it merged together as a new picture.Moving the text around to make a "funny card" type of layout .

Great tutorial. I pushed the click evaluation code back into the object itself, so it is self-aware if a point is inside the image. I needed to do this because I loaded images that had alpha transparency.

/* * True only if the image has a non-transparent pixel at the point that was * clicked. Does NOT account for overlapping images */ public boolean isIntersecting(int x, int y) { boolean retVal = false;

int relativeX = x - mCoordX; int relativeY = y - mCoordY;

// Only do check if the box is in the right range if ( (0 <= relativeX && relativeX < mImage.getWidth()) && (0 <= relativeY && relativeY < mImage.getHeight()) ) { // Now, verify if the point is transparent or not int pixel = mImage.getPixel(relativeX, relativeY); int alpha = Color.alpha(pixel);