Android - Change content view of TabHost - android

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

Related

How to make tabs/sub-fragments inside a tab/fragment in Android

I have implemented an ActionBar with 3 tabs in an android app. I also used ViewPager to switch between different tabs. Every tab is defined in a fragment.
The last tab is called "Setting". I have two different settings. One is "Simple" setting, and the other one is "Advanced" setting. How can I implement these two different settings in the "Setting" tab. Should I make kind of sub-fragments or two new tabs inside the main tab which is "Setting" tab? Can I also for example create two buttons at the top, and switch between them? Or any better idea? Which solution is easier and more efficient. I'm a newbie in Android.
I want to make something like this:
Hope this help
Take SettingFragment as Host fragment
Place both buttons on top and ViewPager below buttons
Take SimpleFragment and AdvanceFragment as items in ViewPager

Add/Remove Tab and its content from tabhost

I have nine tabs(say 0 to 8), displaying only five tabs on screen.
The five tabs will be 0 to 3 of those nine tabs and fifth tab will be MORE Tab.
MORE tab will show Activity with GridView showing Image+Title of remaining nine tabs(say 4 to 8).
Now on click of any item(Image+Title) in GridView will replace the MORE Tab Image+Title and its content/activity with its respective activity.
I am able to replace the tab indicators(Image+Title) but struggling on replace its respective content/activity.
As on other similar thread they had suggested to use clearAllTabs and add/recreate require tabs again. But i feel clearing all tabs just to replace one tab is heavy.
I am using the TabActivity with Intents. As i know TabActivity is deprecated by its old app initially it had only 5 tabs but now requirement is to add few more tabs.
Need your help to implement this. If it not possible with TabActivity, then switching to fragment tabs does it help me?
I trying to implemtent this Image
I would recommend fragments for sure. I've used TabHost in the past and it was very problematic.
You can simply have Button at the top that control the visibility of the fragment below. With this way, you'll even be able to add transitions.
This link give a little more information on that topic. Separate Back Stack for each tab in Android using Fragments

Handling tabs, actionbar, activities and fragments

I am facing problem in designing following scenario :
Showing 3 tabs for contact-lists (all, friends and family)
All tabs would contain contact-list as per the groups
Any contact could be selected and viewed but should be in the same tab (either all,family or frnds)
In short, tabs should be available globally.
Here, I decided to use ActionBar and to change the view by using fragments to be called from onTabSelected() of TabListener; in which I was confused as I have to keep only single activity but multiple fragments.
'Keeping single activity' is this a standard / valid approach ? Please suggest.
Thanks in advance.
You should have a single Activity and have a container(could be an empty LinearLayout) in which fragments are replaced depending on the tab selected.
I know this is late, but I used a tabhost with fragments to do something similar. Here's a nice tutorial.
http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/

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.

Tab layout inside Tab layout

i have develop one application in which tab layout in main file now i would like to set tablayout inside 2nd number tab,so what thing can i do? help me.
its "tab inside tab"
I think you want to give sub-options while clicking on 2nd tab button. For that, why dont you create layout with 2-3 options as you wants. And make it visible/invisible based on the 2nd button's click.
You can make visible/invisible any view by using setVisibility(View.VISIBLE) and setVisibility(View.GONE) method.
I suppose you can't embed a TabHost inside another TabHost. You can do what #Paresh said. Implement your own view switching. If you want an entire Activity embedded - take a look at ActivityGroup or the Fragments framework which you can use through the Compatibility Framework. Good luck.

Categories

Resources