pointToPosition() does exactly what it was meant to do: it converts a
point to a position, that is an index inside your adapter. And it
would be a terrible API on the Adapter itself.

To get the index of a view using pointToPosition() just subtract
getFirstVisiblePosition().

On Mon, Sep 14, 2009 at 1:01 PM, Justin Anderson
<[email protected]> wrote:
> I think we are going to have to agree to disagree on this one.  :)
>
>> You are confusing views and items from the adapter.
>
> I don't believe I am.  Initially I did not realize that the Gallery only has
> visible items as children.  I understand that now.  AFAICT, this was not
> documented anywhere...  Hence the confusion.
>
>> > If I have 20 items, and scroll to the 16th... then that means items 14 -
>> > 18
>> > are visible.  Which in turn means that according to the gallery the item
>> > at
>> > position 0 is really the 14th and the item at position 5 is really the
>> > 18th?  If that is the case, what can I do to get the view I want?
>
>> No, it means the View at index 0 shows the data of the item at
>> position 14 in your adapter.
>
> That is what I meant... I just didn't describe it as well as you did.
>
> I believe that since the gallery deals with displaying views and the
> pointToPosition() method deals with a point on the screen that it should
> return the index of the view at that point, rather than the index of the
> data array.  I think it would be better to have that functionality on the
> adapter, rather than the gallery.
>
> Thank you for your help.  It has helped me understand how things work and I
> now know how to proceed to get the results I want.
>
> Thanks,
> Justin
>
> On Mon, Sep 14, 2009 at 1:25 PM, Romain Guy <[email protected]> wrote:
>>
>> You are confusing views and items from the adapter.
>>
>> > If I have 20 items, and scroll to the 16th... then that means items 14 -
>> > 18
>> > are visible.  Which in turn means that according to the gallery the item
>> > at
>> > position 0 is really the 14th and the item at position 5 is really the
>> > 18th?  If that is the case, what can I do to get the view I want?
>>
>> No, it means the View at index 0 shows the data of the item at
>> position 14 in your adapter. You can use getFirstVisiblePosition() to
>> convert back and forth between index and positions.
>>
>> --
>> Romain Guy
>> Android framework engineer
>> [email protected]
>>
>> Note: please don't send private questions to me, as I don't have time
>> to provide private support.  All such questions should be posted on
>> public forums, where I and others can see and answer them
>>
>>
>
>
> >
>



-- 
Romain Guy
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to