开发者

Opening the activity in another Tab on Click

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 t开发者_如何学Pythonhis? If yes than please tell me how?

Thanks, david


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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜