Android - 在更改选项卡上重新加载WebView

时间:2012-11-12 10:21:48

标签: java android

主要活动:

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    Resources ressources = getResources(); 
    TabHost tabHost = getTabHost(); 

    Intent intentHome = new Intent().setClass(this, Home.class);
    TabSpec tabHome = tabHost
      .newTabSpec("Android")
      .setIndicator("", ressources.getDrawable(R.drawable.home_icon))
      .setContent(intentHome);

    tabHost.addTab(tabHome);
    }

Home.activity:

public class Home extends Activity {

private WebView browser;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home);

    this.browser = (WebView) findViewById(R.id.browser);
    this.browser.setWebViewClient(new WebViewClient());
    this.browser.loadUrl("http://google.com");
}
}

当我更改tab我的Home.activity和WebView重新加载时,我该如何关闭它?感谢您的帮助:)

0 个答案:

没有答案