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.
What about,
journalNames.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id)
{
String selectedFromList = (journalNames.getItemAtPosition(position).getString());
}});
YOu can find it either on view or on parent. In eclipse just type view. and see what methods you get after you type .(dot). I think this is the best.
parent.getAdapter().getItem(position);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.