开发者

Android ImageView clickable overlays

I have a ImageView and draw some things on that view. Now I want to have the position of the click in the onClickListener.

Although I think that's not really possible (storing the position in the onTouchListener is not working), I want to ask, if there is any other way to accomplish that?

The goal is to have a image with s开发者_如何学JAVAome overlays, that should be clickable. I thought about AbsolutLayout, but that is depracated, so what now?

Thx for any help.


Storing position in onTouchListener should work. Did you return false in your onTouchListener ? If you return true, the onClick will never be called. Also note that click can be performed on android without using touch functionality on the device in example by using hardware button. In my opinion you should not use onClickListener for what you're doing, instead handle everything from onTouchListener by handling ACTION_UP as your click event.

Code for android onClick implementation can be found here: http://www.google.com/codesearch/p?hl=en#uX1GffpyOZk/core/java/android/view/View.java&q=android.view.View.java&sa=N&cd=1&ct=rc check the onTouchMethod, it calls performClick method.. which does what it says it does :).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜