Search code examples
androidandroid-viewpagerviewgroup

Using ViewPager with Custom ViewGroups


I'm creating an Android app and I have several custom ViewGroups I've created and wanted to add a ViewPager to my MainActivity so that I can swipe the screen to go back and forth between the Views. However it looks like items added to a ViewPager have to be a Fragment. Do I need to create a separate Fragment for each custom ViewGroup or is there someway to directly add them instead?


Solution

  • Thank you both for your help. I started out using valbertos solution but my app crashed because I tried to access _idLayout before it was set. I ended up finding this solution

    http://architects.dzone.com/articles/android-tutorial-using

    and modified it to fit my needs and it worked great! Thank you both for your suggestions;