Disable Button click sound in android

Android

Android Problem Overview


How to disable click sound of a particular button in Android app?

Here is my code:

more1after.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				sc.scrollTo(sc.getScrollX() + 75,
                sc.getScrollY() + sc.getWidth() + 5);
			}
		});

Android Solutions


Solution 1 - Android

Try this code for disable button click sound effect:

yourbutton.setSoundEffectsEnabled(false);

(or) Layout XML file

 <Button... android:soundEffectsEnabled="false"/>

Solution 2 - Android

In case anyone wonders, here is the XML way:

<Button
    ...
    android:soundEffectsEnabled="false" />

Solution 3 - Android

For those who write code in Kotlin.

button.isSoundEffectsEnabled = false

Solution 4 - Android

<Button
    ......
    android:soundEffectsEnabled="false"/>

Java code

button = findViewbyId(R.id.YourBUttonID);
button.setSoundEffectsEnabled(false);

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAnkit HTechView Question on Stackoverflow
Solution 1 - AndroidDineshView Answer on Stackoverflow
Solution 2 - AndroidyildirimyigitView Answer on Stackoverflow
Solution 3 - AndroidAlfred AfutuView Answer on Stackoverflow
Solution 4 - Androiduser12786901View Answer on Stackoverflow