Ok.  That makes sense.  Thanks for the clarification!

On Mon, Sep 14, 2009 at 3:00 PM, Romain Guy <[email protected]> wrote:

>
> It is clear given its name (but unfortunately not documented).
>
> Index = index of a view inside the gallery
> Position = index of an item inside the adapter
>
> Note the use of the words "index" and "position." They do not mean the
> same thing.
>
> On Mon, Sep 14, 2009 at 1:48 PM, Tikoze <[email protected]> wrote:
> >
> >>pointToPosition() does exactly what it was meant to do: it converts a
> >> point to a position, that is an index inside your adapter
> >
> > I never said it didn't, once I understood its purpose.  It just wasn't
> > clearly documented that it returns an index to the adapter (which is a
> > different object) and I don't think it is a clear choice to have that
> > be the return value when the Gallery itself displays Views that are a
> > subset of the adapter.  If the documentation stated that was the case,
> > or if the method name were a little more clear (perhaps
> > pointToAdapterPosition) then the purpose of the method would be more
> > obvious.  Since the method is on the Gallery class I expected the
> > return value to be pertinent to its particular instance, not to the
> > instance of the adapter that is associated with it.
> >
> >> And it would be a terrible API on the Adapter itself.
> >
> > Point taken.
> >
> > On Sep 14, 2:13 pm, Romain Guy <[email protected]> wrote:
> >> 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 theGalleryonly
> 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 thegallerythe
> 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 thegallerydeals 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 thegallery.
> >>
> >> > 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 thegallerythe
> 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
> > >
> >
>
>
>
> --
> 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