如何调用通过TabBars一个活动 [英] how to call an Activity through TabBars

查看:93
本文介绍了如何调用通过TabBars一个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做其中M使用标签栏的应用程序。 现在我需要知道的是,如何通过 setOnTabChangedListener打开其他选项卡()在我的code

I'm making an application in which m using Tab Bars. Now what i need to know is, how to open other Tab through setOnTabChangedListener() in my code

例如。目前,我的标签,当我点击第二个选项卡上,应该叫第二选项卡的活动。

for example. i am currently in tab and when i click on the 2nd tab it should call the activity of 2nd tab.

推荐答案

看到下面的code

 TabHost tabHost = getTabHost(); // The activity TabHost
        TabHost.TabSpec spec; // Reusable TabSpec for each tab
        Intent intent; // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the Movies tab.
        intent = new Intent().setClass(this, BarActivity.class);
        // Initialise a TabSpec for the Movies tab and add it to the TabHost.
        spec = tabHost.newTabSpec("Nights").setIndicator("Nights").setContent(intent);
        tabHost.addTab(spec);

        // Do the same things for the Theatres tab.
        intent = new Intent().setClass(this, BarActivity.class);
        spec = tabHost.newTabSpec("Weeks").setIndicator("Weeks").setContent(intent);
        tabHost.addTab(spec);

这篇关于如何调用通过TabBars一个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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