How do i reference a songs index position when calling onClick

问题内容:

This is what I want to achieve but in a single text view not the whole list

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int 
    position, long l) {
        // Release the media player if it currently exists because we are about to
        // play a different sound file
        releaseMediaPlayer();

        // Get the {@link Word} object at the given position the user clicked on
        Word word = words.get(position);
    }
}

When I chose onClick I cannot reference the array-list sound resource id.

However on OnItemClick, there is a argument passed in called position that gets the position, however, I don’t want to click the whole list item box just the textview to play the sound.

What do I do similar to the Word word = words.get(position)

But in a onClick Method for a single textview? Any help appreciated.

问题评论:

原文地址:

https://stackoverflow.com/questions/47755874/how-do-i-reference-a-songs-index-position-when-calling-onclick

Add a Comment