Playing default android sound of button, clicking onTouch() method

后端 未结 3 797
旧时难觅i
旧时难觅i 2020-12-08 20:13

In my android app I have some buttons, that should work with onTouch() method, course I need to change button\'s text, when finger in ACTION_DOWN position.

3条回答
  •  悲哀的现实
    2020-12-08 20:34

    Use this code in your onTouch() method:

    view.playSoundEffect(android.view.SoundEffectConstants.CLICK);
    

    If you are simply looking for a preset Android sound then it's better to use this functionality that's provided to you for free by the framework. Doing anything else, unless necessary for customization, would simply result in you working against the framework instead of working with it.

提交回复
热议问题