Sylvester Steele wrote:
> Is there any way to get the item name at a particular position from a
> ListView? If I can't get it from the listView itself, how do I do it?
> 
> the .getItem function returns a weird String, not the actual string
> you see on the screen.

I'm not sure what an "item name" is, and I'm not sure what position 
you're referring to.

If you want the selected item, call getSelectedView().

If you want the view at an arbitrary slot in the visible portion of the 
list, I suspect getChildAt() will do it. Bear in mind that this should 
use indices based on the number of visible rows, not the total number of 
items the adapter will feed to the list. In other words, if you have a 
ListView that, based on fonts and screen sizes and whatnot, shows 10 
items out of a 100-item list, you can get the View for those 10 items. 
Those views probably get reused as the user scrolls, depending on the 
adapter implementation.

In both cases (getSelectedView() and getChildAt()), you get a View back. 
You'll need to cast this to the type of view created by your adapter 
(e.g., TextView) and call methods on it to get out display information 
(e.g., what text is showing in the text view).

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Warescription: All titles, revisions, & ebook formats, just $35/year

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to