Fragments for Horizontal scrolling, use onClicks to move to certain Fragments?

Last Updated:

  1. RED_

    RED_ Well-Known Member

    Hopefully this is do-able.

    I've set up a horizontal scrolling system using FragmentPagerAdapter. Is there a way that I can click on an TextView/ImageView and then it'll take me to one of my Fragments? I want to improve the UI of my app by giving the user the option to scroll left and right but to also click a few buttons on my first Fragment to go to each of the screens too.

    Is this possible?

    I tried an ordinary OnClickListener but that gives me a force close. Mostly because I used startActivity() and I'm not trying to start an activity rather a Fragement but I don't know how to do that.

    Overall maybe there is an easier way though, I've seen apps that have horizontal scrolling and when you click a button on one page you see the scrolling animation take them to the requested page.

    Like I said I have an ordinary FragmentPagerAdapter set up with all the code it's just getting this final bit of the puzzle.

    Any help would be greatly appreciated.

  2. RED_

    RED_ Well-Known Member

    Sorry to bump. Anyone?

    I just want to give the user two options. They can either click on a TextView to take them to one of my Fragments pages. Or swipe left/right to get to that fragment.

    It's the clicking on a TextView bit I can't get. How does one implement that?

Share This Page