Skip to content Skip to sidebar Skip to footer

Detecting Which Item Was Selected From A Listview

I am trying to get the title of the song that was selected from my listview but I'm getting a forced close. Any ideas? ArrayListsongtitle = new ArrayList

Solution 1:

protectedvoidonListIemClick(ListView  , View v, int position, long id){
     Toast.makeText(this, "You have chosen the color: " + songtitle.get(position), Toast.LENGTH_LONG).show();
}

try this.

Solution 2:

selection is not being updated here, it should be computed based on the position. You probably want to something like this:

    ((TextView)v).setText(text);

Also, it looks like songTitle is a list. You should probably rename that to songTitles to begin with. Check that the position is within the bounds of your list. What kind of error are you getting?

Post a Comment for "Detecting Which Item Was Selected From A Listview"