XML
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myWebView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
java的
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
WebView webView = (WebView) findViewById(R.id.myWebView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.google.com");
}
tabview xml
android:id="@android:id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:padding="5dp">
android:layout_width="fill_parent" android:layout_height="wrap_content" />
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:padding="5dp" />
Tabview java
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tabview);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
intent = new Intent().setClass(this, WebActivity.class);
spec = tabHost.newTabSpec("webview")
.setIndicator("webview", res.getDrawable(R.drawable.info))
.setContent(intent);
tabHost.addTab(spec);
// add other tabs
tabHost.setCurrentTab(0);
}
这将以全屏方式启动webView。
是否可以在tabview中显示webview?