Question

I want to create a TabActivity that works like a browser. When the activity is created, it has two tabs: "Tab1" and "Add Tab". When the "Add Tab" is clicked, it should Add a new tab.

Tab 1 | Add Tab
==> Add Tab is clicked
Tab 1 | Tab 2 | Add Tab
==> Add Tab is clicked
Tab 1 | Tab 2 | Tab 3 | Add Tab

...

All my tabs contents are instances of the same Activity.

What is the best way to do that?

Was it helpful?

Solution 2

After trying for a few days, I decided not to use the TabActivity and design my own activity.

Turns out it works really well, far less line of codes and more FPS (I'm using only one View for all my items, and just reset the fields every time I switch from one tab to another.

If anybody is interested I can post the class here, let me know.

OTHER TIPS

You could try setting an onTabChangedListener on your TabHost for clicks on the "Add Tab" tab that would create another tab (using the usual TabSpec methods you used to create your initial tabs), then switch to the newly created tab using the TabHost's setCurrentTab.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top