I am new to android programming & I’m trying to create a simple program where I can handle drag & touch events on different shapes.
From the android API, I understand that it is easy to add event listeners to widgets(eg:ImageView). But how do I do the same for graphics such as RectF or Circle?
Since I’m a novice, I would appreciate if someone could explain in simpler terms.
Things like OnClickListeners can only be added to subsets of the View class.
However, for shapes etc. you can override the onTouch() method for your base layout. Then in MotionEvent.ACTION_DOWN you get the coordinates of the touch point, and see if they intersect with any of your shapes. If it intersects with a shape, then the user clicked that shape, and you can implement whatever code you need to.