The third argument in onItemClick() is position
.
Use this position
to .getItem()
from the ListAdapter associated with your ListView.
You can then get the text from that item in the normal way.
<Additional>
To get the ListAdapter associated with your ListView you would use arg0.getAdapter()
. So the full method call becomes arg0.getAdapter().getItem(position)
.
but as ρяσѕρєя K pointed out, you defined your ListAdapter using the ArrayList called songList.
You defined songList is an ArrayList of HashMaps.
So when you call arg0.getAdapter().getItem(position)
, what will be returned is the HashMap located at that position in your ArrayList called songList.
Since a HashMap is what will be returned, you should write something like:
HashMap selectedItemHashMap = (HashMap)arg0.getAdapter().getItem(position);
You can then retrieve the relevant data from the HashMap with:
selectedItemHashMap.get(...//The relevant key for the data you want to get out of the HashMap...)