Reddy
Reddy

Reputation: 140

Different click listeners for single image

How to create multiple click listeners for one image in android? I have one body image. When I click head it should go to head click listener and if I click legs it should go to leg click listener. How to differentiate like this?

Upvotes: 1

Views: 494

Answers (2)

vnshetty
vnshetty

Reputation: 20132

how system comes to no you click head or anythin other?

i think you can do a hack

  • apply click event listener for whole image
  • and take event.x and event.y to determine which part you clicked and based on that call a function..

Upvotes: 1

Caner
Caner

Reputation: 59268

You need to create a Image map, something like this::

<map name="map-name">
<area shape="rect" coords="135,180,200,185" href="webpage1.html">
<area shape="circle" coords="49,300,42" href="webpage2.html">
<area shape="poly" coords="24,35,55,20,90,42,91,80,60,105" href="webpage3.html">
</map>
<img src="image.gif" usemap="#map-name">

Upvotes: 3

Related Questions