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.
:arrow:
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());
    }

:arrow:
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:
radshak
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Dec 19, 2009 4:37 pm

Top

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(){....});


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

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 9 guests