简体   繁体   中英

something wrong with my webview of android

I am using: windows7, eclipse, sdk up-to-date, avd from android 2.3.3 & milestone <-the NVPACK - in fact the problem is discussed everywhere, but the solutions did not work for me.

When I try to load a url, it turns out a blank white page

some was saying about htmls, but no ,mine is http://www.google.com or http://www.baidu.com or file:///android_asset/demo.html etc.

and the most carried out solutions

the permission:

<uses-permission android:name="android.permission.INTERNET" />

the javscript switcher

mWebView.getSettings().setJavaScriptEnabled(true);

and then my all code: the java

package xiamubobby.inoroy.androidtest;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class WebViewDemo extends Activity {

private WebView mWebView;

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    mWebView = (WebView) findViewById(R.id.webView);
    mWebView.getSettings().setJavaScriptEnabled(true);

    mWebView.loadUrl("http://www.google.com");
}



}

the manifest:

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="xiamubobby.inoroy.androidtest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".AndroidtestActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

the main.xml

    <?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Can anybody tell me what I did wrong? I am hoping for rescue. Since I'm not a very experienced programmer, maybe there be very silly mistakes. Thank you for your patience.

如果WebViewDemo是您的开始活动,则必须更改AndroidManifest.xml :将android:name=".AndroidtestActivity"替换为android:name=".WebViewDemo"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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