android repeat action on pressing and holding a button

后端 未结 6 1858
被撕碎了的回忆
被撕碎了的回忆 2020-11-30 04:09

I want to implement repeat action on pressing and holding a button. Example: When user click on a button and hold it,it should call a similar method again and again on a fix

6条回答
  •  渐次进展
    2020-11-30 04:46

    You can register a View.OnKeyListener for that View. Please take into an account that it is better to debounce such callbacks, otherwise - in case your method doing something even slightly "heavy" - the UI won't be smooth.

提交回复
热议问题