I want to code a button to make a sound when you tap it. If I were to have a sound file like test.ogg or test.wav how could I pull that off? I’m somewhat new to xml so be kinda descriptive. Thanks!
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
android:onClick="sendMessage", and make a function in your activity like this:Whenever the user click your button, it will trigger this function and, therefore, play your sound.