问题
I have an app that is using 3 tabs and each has its own activity. There is also a main class that declares all the tab intents and such. My problem is that I need to use this in each individual activity:
tabHost.setOnTabChangedListener(new OnTabChangeListener(){
public void onTabChanged(String tabId) {
if("TAB_1".equals(tabId)) {
webview2.reload();
}
if("TAB_2".equals(tabId)) {
webview2.reload();
}
}});
I cannot use this because tabHost cannot be resolved, is there a way to pass this through to each individual activity?
回答1:
You don't use that code in each activity, rather you use it in the main activity and reference the webview objects in each activity from there.
来源:https://stackoverflow.com/questions/5212391/help-using-ontabchangelistener