onClick / onLong / onGesture 同时存在时,点击、滑动、长按屏幕的事件处理顺序

在Android开发中,如果一个Activity里面同时继承实现了 onClickListener、onLongClickListener、onGestureListener, 此时手指在点击、滑动、长按屏幕是各个事件处理的顺序是如何的呢,通过实际项目中写日志得到如下的结果:

点击松开: onDown / onShowPress(稍长会有) / onSingleTapUp /onClick
滑动松开: onDown / onScroll(多次) / onFling / onClick / onLongClick
长按松开:onDown / onShowPress / onLongClick / onLongPress
长按并滑动后松开: onDown /onShowPress / onLongClick / onScroll(多次) / onFling

知道这个顺序后,就知道如何处理各个需要的逻辑了,同时需要注意一点:在每个过程中,任何一个事件里面return true了,后面的就将不再执行,如果要同时执行多个事件,可以在每个事件内部处理完后,return false, 后面的事件就将继续进行

0 thoughts on “onClick / onLong / onGesture 同时存在时,点击、滑动、长按屏幕的事件处理顺序”

  1. Please let me know if you’re looking for a article writer for your blog.
    You have some really great articles and I think I
    would be a good asset. If you ever want to take
    some of the load off, I’d love to write some content for your blog in exchange for a link back to mine.
    Please shoot me an e-mail if interested. Thanks!

  2. Hi! I know this is kinda off topic but I’d figured I’d ask.

    Would you be interested in trading links or maybe guest writing a blog post or vice-versa?
    My site addresses a lot of the same topics as yours and I believe we could greatly benefit from each other.
    If you might be interested feel free to shoot me an e-mail.

    I look forward to hearing from you! Excellent blog by the way!

  3. Woah! I’m really enjoying the template/theme of this website.

    It’s simple, yet effective. A lot of times it’s difficult to get that
    “perfect balance” between usability and visual appeal.
    I must say you have done a fantastic job with this. Also, the blog loads
    extremely quick for me on Safari. Excellent Blog!

  4. I believe what you said was very logical. But, what about this?
    what if you were to write a killer headline?

    I am not suggesting your content isn’t solid, however suppose you added
    something to possibly grab people’s attention? I mean onClick
    / onLong / onGesture 同时存在时,点击、滑动、长按屏幕的事件处理顺序 | 李俊麟的平凡生活 is a little plain. You could look at Yahoo’s home page and
    see how they write news titles to get people to open the links.
    You might add a related video or a related pic or two to grab readers excited about everything’ve written.
    In my opinion, it could make your posts a little bit more interesting.

  5. I absolutely love your blog and find most of your post’s to be just what I’m looking for.
    Does one offer guest writers to write content to suit your
    needs? I wouldn’t mind writing a post or elaborating on a lot of the subjects you
    write regarding here. Again, awesome website!

  6. Hey! I know this is sort of off-topic but I had to ask.
    Does running a well-established website like yours take a
    massive amount work? I’m brand new to operating a blog however I do write in my
    journal everyday. I’d like to start a blog so I can easily share my personal experience and feelings online.
    Please let me know if you have any ideas or tips for brand new aspiring bloggers.


  7. Hello there, There’s no doubt that your website
    might be having web browser compatibility issues. When I look at your blog in Safari, it looks fine however when opening in Internet Explorer,
    it has some overlapping issues. I merely wanted to give you a quick heads up!
    Aside from that, excellent site!

  8. Oh my goodness! Incredible article dude! Thank you, However I
    am encountering troubles with your RSS. I don’t know the reason why I can’t subscribe to it.

    Is there anybody else having identical RSS issues? Anyone who knows the solution will you kindly respond?

  9. Its like you read my mind! You appear to know so
    much about this, like you wrote the book in it or something.
    I think that you can do with some pics to drive
    the message home a little bit, but other than that, this is great blog.
    A fantastic read. I’ll certainly be back.

  10. It’s the best time to make a few plans for the longer term and it’s
    time to be happy. I have learn this publish and if I could
    I want to counsel you few interesting issues or tips. Perhaps
    you could write next articles regarding this article.
    I wish to read even more things approximately it!

Leave a Reply

Your email address will not be published. Required fields are marked *

To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image