Hi Mark,
As I was working through this I also found a sample that does just
this in the API. Posting for anyone who may come across this thread:
public class Tabs3 extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("tab1")
.setIndicator("list")
.setContent(new Intent(this, List1.class)));
tabHost.addTab(tabHost.newTabSpec("tab2")
.setIndicator("photo list")
.setContent(new Intent(this, List8.class)));
// This tab sets the intent flag so that it is recreated each
time
// the tab is clicked.
tabHost.addTab(tabHost.newTabSpec("tab3")
.setIndicator("destroy")
.setContent(new Intent(this, Controls2.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
}
}
On Oct 27, 7:25 pm, cyntacks <[EMAIL PROTECTED]> wrote:
> Mark,
>
> Brilliant! Great stuff. I just couldn't think this through in my head.
> You are a lifesaver, I have tried this out and it works perfectly.
>
> Thanks for the help!
>
> Kevin
>
> On Oct 27, 6:35 pm, Mark Murphy <[EMAIL PROTECTED]> wrote:
>
> > cyntacks wrote:
> > > Working with a TabHost, Is it possible to keep the Java code for the
> > > tabs in separate files?
>
> > Sure. There are any number of ways to do this. Here's one:
>
> > -- Your TabActivity (or plain Activity that knows about the TabHost) is
> > one class
> > -- It creates instances of TabOneWrapper and TabTwoWrapper, passing each
> > the View that represents that tab's contents
> > -- TabOneWrapper and TabTwoWrapper are their own classes in their own
> > files, not necessarily subclassing anything in particular
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com
> > _The Busy Coder's Guide to Android Development_ Version 1.3 Published!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---