简体   繁体   English

模拟tabhost单击

[英]Simulate tabhost click

At the moment I am using this to call the TabHost activity to change tabs: 目前我正在使用它来调用TabHost活动来更改标签:

public void switchTab(int index){
    MintTrack ParentActivity;
    ParentActivity = (MintTrack) this.getParent();
    ParentActivity.getTabHost().setCurrentTab(3);
}

This works well, however, the WebView item in tab "3" remains unfocused, until i touch it... 这很好用,但是,标签“3”中的WebView项目仍然没有聚焦,直到我触摸它...

I need to programatically simulate a click on tab 3 then, as clicking the tab automatically places the focus on the webview ... Any ideas? 我需要以编程方式模拟标签3上的点击,然后单击标签会自动将焦点放在webview ......任何想法?

试试这个:

getTabHost().getTabWidget().getChildAt(3).performClick();

我不确定它是否会起作用,但您可以尝试在索引3处为孩子请求焦点。

 ParentActivity.getTabHost().getTabWidget().getChildAt(3).requestFocus();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM