Android Tech

The more we share, the more we get

TabView (Part4) – Create dynamic content in tab at run time


First you should create a simple tab as previous post

After that, you modify code in main activity load the tab as follow:

 

TabSpec spec1=tabHost.newTabSpec(“Tab 1”);
spec1.setIndicator(“Tab 1”);
spec1.setContent(new TabHost.TabContentFactory() {
public View createTabContent(String tag) {
return(new AnalogClock(MainActivity.this));
}
});
spec1.setIndicator(“Clock”);

 

And here is the final result

You can download the source code from here

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: