Android 台灣中文網

標題: 請問如何加一個WEBVIEW 在APP 底下. [打印本頁]

作者: ggbt1    時間: 2015-3-27 00:33
提示: 作者被禁止或刪除 內容自動屏蔽
作者: allblue    時間: 2015-3-27 15:48
可以先把WebView添加到layout的XML文件下面 然後設定寬高

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>


code這邊就再setcontentview下面添加這幾行就行了
WebView webview = (WebView) findViewById(R.id.webView1);
        webview.getSettings().getJavaScriptEnabled();  //讓webview支持javascript的方法
        webview.loadUrl("http://www.jjwxc.net/"); // 打開url連結





歡迎光臨 Android 台灣中文網 (https://apk.tw/) Powered by Discuz! X3.1