My android apps has a regular button:
<Button
android:id="@+id/allOnButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="130dp"
android:text="@string/sensor_management_all_on" />
And a toggle button:
<ToggleButton
android:id="@+id/accelerometerToggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:textOff="off"
android:textOn="on" />
When the button is pressed, a nice "click" sound is played, which gives a good feedback to the user that the button was actually pressed.
How do I set a click sound for the ToggleButton?
For a click sound to be heard, you need clickListener to be set.
So set a dummy onClickListener
onto the ToggleButton
, it should play the sound effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With