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)
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 would like to make a layout that it would be something like this:
A login layout with no toolbar or title bar
A select action layout with toolbar and no tabs
Another layout with toolbar and 3 tabs
and im thinking on how to implement this, how many fragments, activities etc.
I was thinking of having 1 activity full screen and another activity with fragments, toolbar and tab and every time i want a layut with tabs to remove the tabs and in the next screen to add again the tabs.
But after thinking it out it seems like a bad idea.
Should i create a seperate activity with fragments and tabs and navigate around those 3 layouts?
What is the best approach when you want to use tabs and a toolbar but you dont want in all your layouts to have tabs?
You only need 1 Activityand 3 Fragments. In the fragments where you need a toolbar, just use Toolbar view. This is available on Support Library so you will not have problems with older Android versions.
And in the Fragment with the tabs, just use a TabLayout and a ViewPager in order to switch between tabs (each tab is a Fragment).
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 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.