設定Layout和程式權限android.permission.INTERNET
In main.xml
xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView
android:id="@+id/MyIE"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
In AndroidManifest.xml
....
<uses-permission android:name="android.permission.INTERNET" />
...
呼叫WebView的getSettings()得到WebSettings物件來進行設定。
WebView ie;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main );
ie = (WebView) findViewById( R.id.MyIE);
WebSettings webSettings = ie.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(true);
webSettings.setBuiltInZoomControls(true);
}
沒有留言:
張貼留言