Help Using OnTabChangeListener

此生再无相见时 提交于 2019-12-11 16:15:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!