*Hi Zsombor*,
What a coincidence, I'm attempting to do just the same. Have you been able 
to improve the performance with some kind of holder for the viewpagers?
Could you share your code with me by any chance? It would be great because 
i'm trying to do the same with galleries and it's a huge mess.
Thanks x 1000 great to know i'm not alone ;)

Best regards!

El miércoles, 2 de noviembre de 2011 07:23:49 UTC+1, Zsombor escribió:
>
> Found a solution by overriding the onInterceptTouchEvent() of 
> ListView, here it goes: 
>
> ... 
> @Override 
>         public boolean onInterceptTouchEvent(MotionEvent ev) { 
>             //Call super first because it does some hidden motion event 
> handling 
>             boolean result = super.onInterceptTouchEvent(ev); 
>             //Now see if we are scrolling vertically with the custom 
> gesture 
> detector 
>             if (gestureDetector.onTouchEvent(ev)) { 
>                 return result; 
>             } 
>             //If not scrolling vertically (more y than x), don't hijack 
> the 
> event. 
>             else { 
>                 return false; 
>             } 
>         } 
>
>         // Return false if we're scrolling in the x direction 
>         class YScrollDetector extends SimpleOnGestureListener { 
>             @Override 
>             public boolean onScroll(MotionEvent e1, MotionEvent e2, float 
> distanceX, float distanceY) { 
>                 try { 
>                     if (Math.abs(distanceY) > Math.abs(distanceX)) { 
>                         return true; 
>                     } else { 
>                         return false; 
>                     } 
>                 } catch (Exception e) { 
>                     // nothing 
>                 } 
>                 return false; 
>             } 
>         } 
> ... 
>
> As for the recycling: yes, it sucks, there's actually none right now 
> on the vertical axis this way, so the scrolling is a bit clunky, since 
> I'm constructing new ViewPagers. But I have to implement this 
> behavior, so at least it does work. 
>
> On Oct 27, 1:21 am, Dianne Hackborn <[email protected]> wrote: 
> > How exactly do you recycle the list view items correctly?  This is... 
> >  crazy. 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Wed, Oct 26, 2011 at 2:25 AM, Zsombor <[email protected]> wrote: 
> > > I have a ViewPager widget in every row of a ListView. This provides a 
> > > shelf-like UI, so the user can scroll around searching for a shelf 
> > > vertically, and then scroll horizontally amongst the contents of a 
> > > shelf. This works. 
> > 
> > > But the scrolling experience is terrible: if I start to drag a shelf's 
> > > ViewPager, scroll it horizontally, and accidentally drag a bit 
> upwards/ 
> > > downwards, then the ListView "traps" this dragging action, and start 
> > > to scroll vertically, ending my horizontal drag. In this state, the 
> > > drag action won't "return" to the ViewPager, the ListView has it, and 
> > > that's it. I have to start another drag action to affect the ViewPager 
> > > again. So I guess the ListView has precedence in these cases. 
> > 
> > > How can this be fixed? I'd like to achieve the exact opposite: If the 
> > > ViewPager inside a list row starts reacting to a horizontal drag, then 
> > > it should trap that action, and this drag should stop affecting the 
> > > ListView, no matter how the user moves his/her finger vertically. Can 
> > > this be done? 
> > 
> > > -- 
> > > You received this message because you are subscribed to the Google 
> > > Groups "Android Developers" 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-developers?hl=en 
> > 
> > -- 
> > Dianne Hackborn 
> > Android framework engineer 
> > [email protected] 
> > 
> > Note: please don't send private questions to me, as I don't have time to 
> > provide private support, and so won't reply to such e-mails.  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 Developers" 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-developers?hl=en

Reply via email to