Android ListView and OnClickListener: How to get the selected item

androidandroid-listview

I have a listView vith some items.

I would like to get from my onClickListener the name (String) of the selected item.

I know how to get the selected position but how to find the String of this element?

Here is my on click listener:

journalNames.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) 
    {

    }});

My listView is populated with some query from the database.

Thank you.

Best Solution

What about,

journalNames.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) 
    {
      String selectedFromList = (journalNames.getItemAtPosition(position).getString());
    }});