Using TabView without TabActivity android - android

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

Related

Second set of tabs in an Android 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

Add FragmentActivity inside a tab on Android ActionBar tab.

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.

Making one of the actionBar tabs have a view pager

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)

Android - Change content view of TabHost

I try to create a android application with tabHost and I would like to avoid to set intent(activity) for the content of these tabs.
I succeed to create my tabMenu but I would like to change the view of one tab.
How I can do that ?
For example I have one view for Tab1 and two views for Tab2 (when the user click on the button of Tab2_view1 then the content change to Tab2_view2 and the indicator doesn't change (stay on "tab2")).
I hope it is possible but I don't find the way to do that without using different activities for each tabs.
Maybe my conception is bad (I am novice in Android dev.)...
Thank you very much for your help,
Fred
Android has ActivityGroup for the same purpose that you are looking for. By using ActivityGroup you can show multiple views in a single Tab by maintaining the stack of the Views.
ActivityGroup Example 1
ActivityGroup Example 2
Fragment - Answer to me by hackbod

add dynamic view to android tabhost

How can I add a dynamic view in a TabHost.
I have two tabs i.e. TabA and TabB. In TabA, I have 2 buttons and I want to set the layout (I have 2 different XML layout's) of TabB, depending upon the button pressed in TabA.
Can anyone help me.
Thank you!
That depends on the implementation of your TabHost. Have you used Activities or Views as Tabs?
Generally in your TabActivity you could use getTabHost().getTabWidget().getChildAt(index) or another method to get the view of a Tab.
If you use Activities as the children, you could also start a new Intent with your ActivityGroup and set a new view within the onCreate() method.
If you have problems finding examples for ActivityGroups with TabHosts, I can provide you a code sample showing you how to do it and also how to change the view within another tab by clicking a button.

Categories

Resources