12. Adding audio #
Created Sunday 10 January 2021
Part 1 #
That’s okay, but how will the user ‘see’ the audio option.
- We’ll add a play icon in
list_item.xml - We’ll attach an event listener to the row, which will play the audio.
Part 2 #
How to we add audio to the Miwok app?
- We’ll store the audio files in
/res/raw - As audio is linked to a Word, we’ll add an
intresource in the Word class. - We’ll initialize this value in the respective category_activity.java file
Part 3 #
Which class will have the method for playing audio, and setting the listener. There can be several approaches:
- Change the Word class - we’ll have two methods, one for setting the audio_ID and the other for attaching the listener which will play the audio. But WordAdapter handles view, not Word. This will make Word interactive, which is not desired because Word’s primary motive is to carry data. We’ll have to pass the view to Word from WordAdapter.
- Change WordAdapter class - As this controlls the view, it is easier to attach the listener here.
Part 4 #
Visual Polish