Android 单个图像的不同单击侦听器

Android 单个图像的不同单击侦听器,android,image,clicklistener,Android,Image,Clicklistener,如何在android中为一个图像创建多个单击侦听器? 我只有一个身体形象。当我点击头部时,它应该转到头部点击监听器,如果我点击腿部,它应该转到腿部点击监听器。如何像这样区分?您需要创建一个图像映射,类似于这样: <map name="map-name"> <area shape="rect" coords="135,180,200,185" href="webpage1.html"> <area shape="circle" coords="49,300,42" h

如何在android中为一个图像创建多个单击侦听器?
我只有一个身体形象。当我点击头部时,它应该转到头部点击监听器,如果我点击腿部,它应该转到腿部点击监听器。如何像这样区分?

您需要创建一个图像映射,类似于这样:

<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">

您需要创建一个图像映射,如下所示:

<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">

系统是如何停止的?你点击头部还是其他部位

我想你可以做一个黑客

  • 为整个图像应用单击事件侦听器
  • 并使用event.x和event.y来确定您单击了哪个部分,并基于该部分调用函数

系统是如何停止的?你点击头部还是其他部位

我想你可以做一个黑客

  • 为整个图像应用单击事件侦听器
  • 并使用event.x和event.y来确定您单击了哪个部分,并基于该部分调用函数