发布于 2021-02-08 21:36:17
我试着回答这个问题并且工作了.
Can't play sound on button click using playSoundEffect(SoundEffectConstants.CLICK)
val context = AmbientContext.current
...
OutlinedButton(
content = { Text("OK") },
onClick = {
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
audioManager.playSoundEffect(SoundEffectConstants.CLICK,1.0f)
}
)
https://stackoverflow.com/questions/66080018
复制相似问题