Android : How to implement longpress manually in touch event?

前端 未结 4 1975
庸人自扰
庸人自扰 2021-02-11 05:07

Short version: I want a way to start a time-based counter on an onTouchEvent, and test to see if a certain amount of time has passed before responding, as a manual LongTouch det

4条回答
  •  自闭症患者
    2021-02-11 05:58

    The way I would approach this would be to set some boolean to true when Action_Down occurs. If action_up occurs then set the boolean to false. Also start a postDelayed set to whatever delay you want when action_down occurs. In the postdelayed, if the boolean that you earlier set to true is still true then do what you want. Sorry for such a wordy answer but that is how I would do it.

提交回复
热议问题