Skip to content
Advertisement

Android how to play different sound for each item in recyclerview

I build app with images of animals, and after you click on animal, its play sound for that animal.

I use Recyclerview for displaying all animals items.

My problem is that i do not know how to handle click event for playing sounds for each animal. I do know how to play same sound for each item in recyclerview but i do not know how to handle specific sound for each item.

this is code for my class where i handle data, where i put all animal names, images and sounds for each object.

JavaScript

This is code for Adapter, and here i handle click and when i click on item, it play the same sound but how to play different sound for each animal, not the same sound like here. Here i always play sound R.raw.clock

JavaScript

Advertisement

Answer

Refer the link https://gist.github.com/grantland/cd70814fe4ac369e3e92

you can refer to the item click event and how to get the item on click event

please refer the code below. i have made the changes

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement