I have an app with a TabHost and three tabs. He is an example of how I am creating each tab:
intent = new Intent().setClass(this, Setup.class); //intent.getClass()
spec = tabHost.newTabSpec("setup").setIndicator("",
res.getDrawable(R.drawable.tab_setup))
.setContent(intent);
tabHost.addTab(spec);
My goal is, when you switch to a new tab, to call a method updating the information displayed on that tab.
Here is the question: How does a tab know it has been displayed?
Since you are using an
Activityfor each tab in yourTabHost, you should use the Android lifecycle calls to update the information on your UI.onResumeis called every time you switch to another tab’sActivity(onPauseis then called in the last tab’s activity). This will keep your code in the proper place, in case you ever decide to use a different UI to host these activities.