views:

776

answers:

1

Hello stackoverflow,

I recently started Android programming and was working on my first program which displays a historic text document, sectioned by tabs via TabHost. I have limited my program to one activity and merely used setContent in my TabSpec's to switch between different XML views.

The document has both unedited and corrected versions of the text for which I have built text views to accommodate. I wanted to implement the standard menu to have buttons to "view corrected" and "view original" and switch the content of the tabs which have changes (without altering the tabs or their indicators).

I've read on the TabHost API and there is no way to edit existing tab content with setContent() of TabSpec; and AFAIK TabWidget only affects the actual tabs, not the content that is displayed upon pressing them.

I've thought about creating a new class which extended TabHost and super() all of the original methods, while including one more which updated the mTabSpec list.

My question would be, how would I update the frameLayout view of a specific tab to display content I specify?

A: 

I would point you in 2 possible directions.As it's a bit late I won't go into details, and If you have no answer tomorrow, I'll give you some more: You can use the ViewSwitcher class, that is really great for this kind of thing when you have 2 views to deal with.You can find a good tutorial here. Or you can create the 2 Views one on top of the other and when you click your button to go from original to corrected just change the attribute visibility from VISIBLE to GONE and the opposite for the other view. But it's less nice coding than the previous way, though much easier to code (nice to test your views)

Hope that helps,

Sephy

Sephy