It is a matter of efficiency ... why your method is onCreatenot called twice or more times. The eaiser way to access your activity from yours is TabActivitythrough the OnTabChangedListenerfollowing:
public class YourTabActivity extends TabActivity{
public void onCreate(Bundle InSavedInstanceState) {
super.onCreate(InSavedInstanceState);
final TabHost tabHost = getTabHost();
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
public void onTabChanged(String tabId) {
if( tabId.equals("the_id_of_your_tab") ){
NameOfThatActivity.self.theMethodYouWantToCall();
}
}
});
}
}
Then, in your child activity, you have something like:
public class NameOfThatActivity extends Activity{
public static NameOfThatActivity self;
public onCreate(Bundle b){
super.onCreate(b);
self = this;
}
public void theMethodYouWantToCall(){
}
}
This is not beauty, but it works great.
source
share