我正在使用 LinearLayout(内部有一些 View )来表示“设置”屏幕中的声音开/关按钮。
当我将 OnClickListener 设置为此布局时,它会在单击时自动播放系统“onClick”声音。
我只想在声音从“NoSound”变为“Sound”时播放声音。另一种情况下如何抑制声音?
最佳答案
您是否尝试过使用 setSoundEffectsEnabled(false/true);
,它应该按照文档说明工作
Boolean that controls whether a view should have sound effects enabled for events such as clicking and touching.
关于java - 为 View 禁用 onClick 声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14646413/