I have a tab bar view created using FragmentActivity. I also have separate sliding ViewPager, created using FragmentActivity. I just need to add this sliding ViewPager inside one of the tab on the my tab bar view. Basically I need to have sliding view inside one of the tab (not the swipe view with tab). I am using Android 4.0 and above.
Can anyone please help me on this ?
This is not possible. You cannot "Add FragmentActivity inside a tab on Android ActionBar tab". Activities-inside-of-activities has been deprecated for ~30 months and never supported action bar tabs.
One possible alternative is for you to change your ViewPager to be inside a Fragment, instead of a FragmentActivity. If the ViewPager is using a fragment-based PagerAdapter, it can do so using nested fragments -- use getChildFragmentManager() when creating your PagerAdapter. Here is a sample project demonstrating a ViewPager in a fragment and using nested fragment for pages.
Related
I want to add two tabs to my Android app.
Tab 1: To do tasks
Tab 2: Done tasks
The layout in both views is the same (the only thing changing is the data shown). It's a gridlayout with cardviews.
How can I implement the tab/swipe action that changes from one to another being both the same .xml?
Android documentation is outdated and many of the methods used here are deprecated.
You can use viewPager and tabLayout for that swipefeature and call your fragments through custom adapter by extanding FragmentPagerAdapter in that
.
I want to add a second row of tabs to my Android application on the second fragment accessed from the ActionBar tabs.
Tab 1 shows fragment 1.
Tab 2 shows fragment 2 but I would like fragment 2 to have a second row of tabs so it will show fragment a or b.
But it seems like fragments within fragments cannot be done and an ActionBar submenu can't be switched on or off. I have also tried with a FragmentStatePagerAdapter with a TabHost and a ViewPager which displays the tabs fine but does not display the fragments. Is there any other way to do this?
If you know the new Design Support Library ....
In your second fragment you can use TabLayout introduced in design support library 22 . Which is same as Actionbar tabs.
So just add the TabLayout in your second fragment XML.
And TabLayout has a method setUpWithViewPager(). So you can easily setup your tabs.
I hope it helps you.
here is the reference http://android-developers.blogspot.in/2015/05/android-design-support-library.html
Is it possible to use TabView without using TabActivity.
All samples I could find are based on TabActivity only.
Can someone please point to a sample where TabView is used as a child of activity to host another set of activities in its tabs
Yes you need a ViewPager and then you can add tabs to show the current fragment of the view pager:
ViewPager with tabs
I am trying to make an app to do the following function:
I need to have an ActionBar with 3 tabs such that one of the tabs has to implement a ViewPager and the other 2 tabs has to have separate layouts.Although I know how to create an ActionBar with Tabs with fragments, I am not sure how to(or if it is even possible) to implement a ViewPager inside one of the tabs.Thanks a lot for your help.
Edit:Nvm I found the solution.You have to use nested fragments.For more information refer to
How to add a Fragment inside a ViewPager using Nested Fragment (Android 4.2)
I have a FragmentActivity which can swipe through several fragments via ViewPager and a FragmentActivity which hosts an ActionBar for navigation.
Now I want to nest the FragmentActivity with the ViewPager in the first fragment of the other FragmentActivity which hosts the ActionBar.
In other words I like to have an ActionBar navigation and in it's first Tab I'd like to have swipeable fragments.
My problem is how to nest one FragmentActivity in another FragmentActivity. Both work on their own but I don't get them to work together.
Swipe Gesture applied at Fragment level along with ViewPager with it's default swipe disabled
You can write your own touch interceptor for the fragments inside your view-pager.
However on a second opinion, please see my moqup in the question:
You can have several ViewGroup container preferably FrameLayout, where on each you can add or remove fragments using transactions. The container of the Navigation Panel is different than where the ViewPager is showing:
Keep this ViewPager in a separate fragment that spawns in yet another FrameLayout. in ViewPager here you should not use the FragmentPageAdapter, but a regular PagerAdapter (avoid nesting of fragments). Hence the ViewPager is a parent container for the Views, and not Fragments where they are shown.
The target of the navigation drawer (on item click) will be this second FrameLayout. Keep it simple!!
Similarly you can have a ViewPager inside a first tab of Tab based ViewPager with this new found information.