帮助使用OnTabChangeListener [英] Help Using OnTabChangeListener

查看:302
本文介绍了帮助使用OnTabChangeListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用3个标签的应用程序,每个人都有自己的活动。也有声明的所有标签的​​意图和这样一个主类。我的问题是,我需要在每一个人的活动来使用:

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();
               }
    }});

我不能用这个,因为tabHost解决不了,有没有办法通过对每一个人的活动来传递这个?

I cannot use this because tabHost cannot be resolved, is there a way to pass this through to each individual activity?

推荐答案

您不要使用code中的每个活动,而你的主要活动使用它,并引用从那里每个活动web视图对象。

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.

这篇关于帮助使用OnTabChangeListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆