coding 101 - listview & getSelectedItem

Put your problem here if it does not fit any of the other categories.

coding 101 - listview & getSelectedItem

Postby radshak » Sat Dec 19, 2009 4:54 pm

Ok So I have a Listview in my extended ListActivity class.
And then I have this code to detect my click on the list
Code: Select all
protected void onListItemClick(ListView l, View v, int position, long id)
       Log.i("", ""+l.getSelectedItem().toString());

I want to get the data string associated to my click.
I checked the api reference.
Listview extends AdapterView where getSelectedItem() is defined.
But when I run the code, I get an error with getSelectedItem(). And when I checked the API for ListView, getSelectedItem() is not in the inherited methods.
How is that possible? :roll:
Once Poster
Once Poster
Posts: 1
Joined: Sat Dec 19, 2009 4:37 pm


Postby qlimax » Sun Dec 20, 2009 11:53 pm

getSelectedItem is inherited from the AdapterView class (as described in the doc)

for your problem, I suggest you tu use getListView().setOnItemClickListener(new OnItemClickListener(){....});

¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
Master Developer
Master Developer
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss


Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 6 guests