• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

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

RED_

Well-Known Member
Nov 13, 2010
209
8
London
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.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones