how to define image which user clicked

Problems with Canvas, OpenGL, etc...

how to define image which user clicked

Postby freedom_life93 » Sun Oct 02, 2011 6:28 am

now i have 2 image in screen and two corresponding coordinates , i want to define image which user clicked,plz show me how can i do this ?
freedom_life93
Freshman
Freshman
 
Posts: 5
Joined: Wed Sep 28, 2011 10:55 am

Top

Re: how to define image which user clicked

Postby jonbonazza » Mon Oct 03, 2011 2:36 am

Use an OnTouchListener and compared the returned point of touch to the images' locations.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Re: how to define image which user clicked

Postby freedom_life93 » Mon Oct 03, 2011 10:04 am

jonbonazza wrote:Use an OnTouchListener and compared the returned point of touch to the images' locations.
if i only have name or id of image , can i use OnTouchListener to know image user clicked?
freedom_life93
Freshman
Freshman
 
Posts: 5
Joined: Wed Sep 28, 2011 10:55 am

Re: how to define image which user clicked

Postby jonbonazza » Mon Oct 03, 2011 3:13 pm

you can create an ImageView to define the image useing its ID and then use its accessor methods to get the x coordinate, y coordinate, width, and height to define the bounds of the image and compare it to the point of click.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Re: how to define image which user clicked

Postby freedom_life93 » Tue Oct 04, 2011 4:25 am

jonbonazza wrote:you can create an ImageView to define the image useing its ID and then use its accessor methods to get the x coordinate, y coordinate, width, and height to define the bounds of the image and compare it to the point of click.

thanks you so much ! Let me try
freedom_life93
Freshman
Freshman
 
Posts: 5
Joined: Wed Sep 28, 2011 10:55 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: Google Feedfetcher and 3 guests