Using the compatibility library with the Fragment Pager Support
example, I'm noticing some odd behavior in the scrolling.
To reproduce:
1. Run the sample FragmentPagerSupport (v4)
2. From Fragment #1 scroll up and down using the dpad or trackball.
- This works as expected.
3. Swipe to move to Fragment #2.
4. Scroll up and down using the dpad or trackball.
Nothing appears to happen. However, you are actually scrolling on
Fragment #1. Not the visible fragment. In fact, you can use the left/
right arrows (trackball roll left/right) to move the focus to the
offscreen fragments and scroll around on those.
If you connect an item click listener to the lists and display a toast
message, you will see that while scrolling on the off-screen
fragments, pressing the dpad-center or trackball, you will trigger the
click response for that offscreen list item.
I noticed this in my own application and confirmed with the sample
app.
Is there any way around this? Can we restrict focus/scrolling only to
the onscreen fragment?
-- setting the focus when you switch pages -- using android:nextFocusDown and kin on your widgets to control how the focus switches
(note that I haven't used the pager component yet, so the above advice is an educated guess)
However, bear in mind that not everybody uses touchscreens. If you make it impossible to navigate through all fragments with the pointing device, you will alienate those users.
On Thu, Sep 22, 2011 at 8:25 AM, Eric Carman <ewcarma...@gmail.com> wrote: > Using the compatibility library with the Fragment Pager Support > example, I'm noticing some odd behavior in the scrolling.
> To reproduce:
> 1. Run the sample FragmentPagerSupport (v4) > 2. From Fragment #1 scroll up and down using the dpad or trackball. > - This works as expected. > 3. Swipe to move to Fragment #2. > 4. Scroll up and down using the dpad or trackball.
> Nothing appears to happen. However, you are actually scrolling on > Fragment #1. Not the visible fragment. In fact, you can use the left/ > right arrows (trackball roll left/right) to move the focus to the > offscreen fragments and scroll around on those.
> If you connect an item click listener to the lists and display a toast > message, you will see that while scrolling on the off-screen > fragments, pressing the dpad-center or trackball, you will trigger the > click response for that offscreen list item.
> I noticed this in my own application and confirmed with the sample > app.
> Is there any way around this? Can we restrict focus/scrolling only to > the onscreen fragment?
> Thank you.
> Best Regards, > Eric
> -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscribe@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en
Using the dpad left/right or trackball roll left/right doesn't simulate a swipe. All it does is set focus to an offscreen fragment. It doesn't actually change the fragment that is displayed on screen. (I have on screen buttons that will let the user "swipe" left/right if they are touch-screen challenged. I'm referring to the sample app because it is easier for folks to reproduce if they feel inclined.)
The Android Market App doesn't do this. It appears to behave such that when you are on the pages that allow you to swipe left/right - the dpad/trackball options will let you select widgets up/down/left/right, but only on the on-screen fragment.
Fragment #0 | Fragment #1 | Fragment #2 <off screen>| <on screen> | <off screen>
Each fragment presents a list. Scrolling left/right will move the focus between each of these fragments without changing which one is on screen. Selecting an item while the focus is off screen, will select whatever happens to be focused on the offscreen fragment. Not a great experience.
To address your suggestions. I suppose it would be possible to trap the focus using the nextFocus<direction> options. The tricky part then is to know that your fragment has been made the on-screen fragment.
The V4 (rel 3) compatibility library doesn't seem to expose that feature - or I've missed it completely. There doesn't appear to be an onChange type listener that let's me know when the fragment was changed. But I suppose that is a question for another post.
In any event, it seems like this navigation paradigm is a little dodgy if it was intended to allow the user to select offscreen fragments and act on them.
On Thu, Sep 22, 2011 at 6:27 PM, Eric Carman <ewcarma...@gmail.com> wrote: > To clarify...
> Using the dpad left/right or trackball roll left/right doesn't > simulate a swipe. All it does is set focus to an offscreen fragment. > It doesn't actually change the fragment that is displayed on screen. > (I have on screen buttons that will let the user "swipe" left/right if > they are touch-screen challenged. I'm referring to the sample app > because it is easier for folks to reproduce if they feel inclined.)
> The Android Market App doesn't do this. It appears to behave such that > when you are on the pages that allow you to swipe left/right - the > dpad/trackball options will let you select widgets up/down/left/right, > but only on the on-screen fragment.
> Fragment #0 | Fragment #1 | Fragment #2 > <off screen>| <on screen> | <off screen>
> Each fragment presents a list. Scrolling left/right will move the > focus between each of these fragments without changing which one is on > screen. Selecting an item while the focus is off screen, will select > whatever happens to be focused on the offscreen fragment. Not a great > experience.
> To address your suggestions. I suppose it would be possible to trap > the focus using the nextFocus<direction> options. The tricky part then > is to know that your fragment has been made the on-screen fragment.
> The V4 (rel 3) compatibility library doesn't seem to expose that > feature - or I've missed it completely. There doesn't appear to be an > onChange type listener that let's me know when the fragment was > changed. But I suppose that is a question for another post.
> In any event, it seems like this navigation paradigm is a little dodgy > if it was intended to allow the user to select offscreen fragments and > act on them.
> Thank you for your quick response.
> -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscribe@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en
On Thu, Sep 22, 2011 at 5:25 AM, Eric Carman <ewcarma...@gmail.com> wrote: > Using the compatibility library with the Fragment Pager Support > example, I'm noticing some odd behavior in the scrolling.
> To reproduce:
> 1. Run the sample FragmentPagerSupport (v4) > 2. From Fragment #1 scroll up and down using the dpad or trackball. > - This works as expected. > 3. Swipe to move to Fragment #2. > 4. Scroll up and down using the dpad or trackball.
> Nothing appears to happen. However, you are actually scrolling on > Fragment #1. Not the visible fragment. In fact, you can use the left/ > right arrows (trackball roll left/right) to move the focus to the > offscreen fragments and scroll around on those.
> If you connect an item click listener to the lists and display a toast > message, you will see that while scrolling on the off-screen > fragments, pressing the dpad-center or trackball, you will trigger the > click response for that offscreen list item.
> I noticed this in my own application and confirmed with the sample > app.
> Is there any way around this? Can we restrict focus/scrolling only to > the onscreen fragment?
> Thank you.
> Best Regards, > Eric
> -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscribe@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en
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.