开发者

How can i invoke a tab from another tab in android?

I am using the android tab layout. I have 4 tabs.My first tab "Home" is a list view.I want to invoke the fourth tab on the click of a list item in my "Home" tab.How can i achiei开发者_开发问答ve this?


You can put this inside a child activity:

((YourTabActivity)getParent()).getTabHost().setCurrentTab(1);

In the case above, the second tab will be selected. Or if you use tags to reference your tabs, which is recommended, you can use:

((YourTabActivity)getParent()).getTabHost().setCurrentTabByTag("MY_SECOND_TAB");


Add a ListView.onItemClickListener

listView.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView av, View v, int position, long id) {
        mTabHost.setCurrentTab(3);
    }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜