Sound FX touches to Note To Self
As it has become customary over the last few chapters, we will use our new-found knowledge to add an enhancement to our Note To Self app. This chapter will be the last time we do this, however, before we move on to new coding pastures.
Using your operating system's file browser, go to the app\src\main
folder of the project and add a new folder called assets
.
There is a sound file called beep.ogg
ready-made for you in the Chapter 17/Note To Self/assets
folder of the download bundle. Of course, you can make your own sound FX using Bfxr if you prefer.
Place the file into the assets
directory that you just created.
Now, we can add some Java code to play the beep sound each time a note from the list is selected.
First, let's add a couple of new member variables to the MainActivity
class:
public class MainActivity extends AppCompatActivity { Animation mAnimFlash; Animation mFadeIn; int mIdBeep = -1; SoundPool mSp; private NoteAdapter mNoteAdapter...