Thanks for checking out my inquiry!
I have implemented a tab environment as illustrated below. It seems to work as I expected except that it never executes the onTabChanged method. I have found several posts about this type of situation but have not been able to get my code to work the way I expected. Advice?
Thanks, Chip
public class TestTabActivity extends TabActivity implements OnTabChangeListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
intent = new Intent().setClass(this, Page1Activity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = tabHost.newTabSpec("page1").setIndicator("Page 1",
res.getDrawable(R.drawable.ic_tab_page1))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, Page2Activity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = tabHost.newTabSpec("page2").setIndicator("Page 2",
res.getDrawable(R.drawable.ic_tab_page2))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, Page2Activity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = tabHost.newTabSpec("page3").setIndicator("Page 3",
res.getDrawable(R.drawable.ic_tab_page3))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
public void onTabChanged(String tabId) {
Log.d("Tab Changed", "Changed a Tab");
}
}