Addev
Addev

Reputation: 32243

Disable onClick sound for a View

I'm using a LinearLayout (with some views inside) for representing the sound On/Off button in the Settings screen.

When I set the OnClickListener to this Layout it automatically plays the system "onClick" sound when clicked.

I'd like to play the sound only when the sound is going from 'NoSound' to 'Sound'. How can I supress the sound in the other case?

Upvotes: 1

Views: 587

Answers (1)

Waqas
Waqas

Reputation: 6802

Have you tried using setSoundEffectsEnabled(false/true); which should work as per documentation that

Boolean that controls whether a view should have sound effects enabled for events such as clicking and touching.

Upvotes: 4

Related Questions