Hi I just start learning Android development and sometimes I faced with issue I can't to solve it by myself. For now I learn the RycyclerView structure, and for this purpose create different sample app. For now I wanna create the Alphabet grid with feature: when user click to letter should sound the letter pronunciation.
PS: I've already found this: answer it's not solve my question
- I created the AlphabetActivity.kt Link to git The file is large for implamenting right here so I added the link to the github resource.
- I created the AlphabetAdapter.kt Link to adapter In the adapter there is a chunk of code for mamaging click on the letter image:
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
val charItem: CharItem = arrayList.get(position)
holder.icons.setImageResource(charItem.icons!!)
holder.titles.text = charItem.alpha
holder.icons.setOnClickListener {
Toast.makeText(context, "Position ${position}", Toast.LENGTH_LONG).show()
}
}`
I got it how to display Toast message but I haven't ideas how to play sound. Of course I tried to implement some ideas: created the LetterSound.kt with array of sound file, and try to connected click on the letter with sound position from this array using when(){} but without any success. Please give me some advice, help me figure out how to properly implement this functionality.