0

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

Nick
  • 949
  • 1
  • 11
  • 31
amsiddh
  • 3,513
  • 2
  • 24
  • 27

1 Answers1

0

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

Community
  • 1
  • 1
Frank Sposaro
  • 8,511
  • 4
  • 43
  • 64
  • To add, I just checked out your iOS image that you are trying to do. Looks like you should think about using the action bar. Then you won't even have to deal much with fragments or custom implementation. It will also take care of the overflow menu as well. Check out http://actionbarsherlock.com/ – Frank Sposaro Jun 08 '12 at 14:47
  • Frank Thanks for your reply. Currently some what i am able to achieve expected results by loading/setting all tabs initially and more tab at the end. Further just hiding the extra tabs by "mTabHost.getTabWidget().getChildTabViewAt(pos).setVisibility(View.GONE);" and showing only required one, its just trick and bit logic to toggle between gone and visible, still working on this. I agree with your suggestion of fragments but due to time constraint, thinking to do later. About action bar suggestion, i didn't have much idea is can i show tabs like iphone(at bottom) using action bars? – amsiddh Jun 09 '12 at 19:05
  • Yep. The actionbar is literally just the your iphone mock at the bottom (or top). You can even have the "..." button to show more choice. This is called the overflow menu. If I have helped you, just please accept my answer so it can help others! ty. – Frank Sposaro Jun 10 '12 at 00:03
  • I am able implement as required by setting hiding/gone property to tab views, as i explained in my previous comment. @Frank i accept your answer as it gave some other ideas for implementation. – amsiddh Jun 13 '12 at 07:51