“Press and hold” button on Android needs to change states (custom XML selector) using onTouchListener

后端 未结 5 1400
北恋
北恋 2020-12-09 17:01

I\'ve got a button graphic which needs to have \"press and hold\" functionality, so instead of using onClickListener, I\'m using onTouchListener so that the app can react to

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 17:33

    You can just set the button onClickListener and leave its onClick method empty. Your logic implement inside onTouch. That way you'll have the press effect.

    P.S You don't need all those state in the selector you can simply use:

    
    
    
        
    
        
    
    
    

提交回复
热议问题