打开在另一个标签的活动上点击 [英] Opening the activity in another Tab on Click

查看:92
本文介绍了打开在另一个标签的活动上点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用TabHost和我想开一个网页,当我点击的项目从一个选项卡的列表到另一个选项卡。

I am using TabHost in my application and I want to open a webPage when I click on the Item from the List of one Tab into the another Tab.

我指的是列表是一个标签,当我点击一个项目从名单中,我想在另一个选项卡中打开网页。

I mean the list is in one Tab and when I click on an item from the list, I want to open the WebPage in to another Tab.

我可以母鹿呢?如果是比请告诉我怎么样?

Can I doe this? If yes than please tell me how?

谢谢, 大卫

推荐答案

在假设你有你的标签设置是这样的:

In the assumption that you've got your tabs setup like this :

LocalActivityManager localActivityManager = new LocalActivityManager(this, false);
tabHost.setup(localActivityManager);

TabSpec spec = tabHost.newTabSpec("tab1").setIndicator("My List").setContent(R.id.layout_tab1);
tabHost.addTab(spec);

spec = tabHost.newTabSpec("tab2").setIndicator("My Browser").setContent(R.id.layout_tab2);
tabHost.addTab(spec);

在你的动作(一个按钮单击下面的代码片段),只需将当前选项卡上的tabhost。

In your action (a button click in the snippet below), just set the current tab on your tabhost.

btnSearch.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        tabHost.setCurrentTab(1);
    }
});

这篇关于打开在另一个标签的活动上点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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