简体   繁体   中英

jQuery Mobile not working in WebView

I'm using jQuery mobile and html5. I want to include my page DIstance2.html in webview, but it's showing like an html page, not a jQuery mobile page. This my code in Android using a webview, version of my jQuery mobile is 1.4.1 and jQuery 1.11.

package com.example.webapp.com;

import com.example.webapp.com.R.string;

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebSettings;
import android.webkit.WebView;

@SuppressLint("SetJavaScriptEnabled") public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String url="http://192.168.1.4/dream-html5/api/Distance2html.html";
        WebView wvSite = (WebView)findViewById(R.id.webview);


        //...on active JavaScript...
        wvSite.getSettings().setJavaScriptEnabled(true);
        wvSite.getSettings().setDomStorageEnabled(true);


        //...et on charge la page

        wvSite.loadUrl(url);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}

在您的项目中添加资产文件夹,然后从此处调用您的html网址,例如wvSite.loadUrl(“ file:///android_asset/dream-html5/api/Distance2html.html”)

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