我正在尝试使用playSoundEffect()
方法在按钮被点击时播放声音效果,但是目前由于某些原因它非常困难。
我定义了以下内容。
<ImageButton android:id="@+id/Button_flip" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="FLIP!"
android:src="@drawable/flip" android:soundEffectsEnabled="true">
</ImageButton>
然后,
button_flip.playSoundEffect(android.view.SoundEffectConstants.CLICK);
在onCreate()方法中调用。但是当我点击按钮时似乎无法发出声音。我错过了什么?文档没有太多信息可供参考。
我是否需要在onClick()方法中定义/调用?
非常感谢任何帮助。