views:

25

answers:

0

Hello,

I'm trying to use the playSoundEffect () method to play a sound effect when a button is clicked, but so far its' proved very difficult for some reason.

I have defined the following.

<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>

Then,

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

is called in onCreate() method. But I cannot seem to get it to sound when I click the button. What am I missing here? The documentation has nothing much to go on.

Do I need to define/call in the onClick() method?

Any help is appreciated.

Thank you.