【问题标题】:jQuery Mobile not working in WebViewjQuery Mobile 在 WebView 中不起作用
【发布时间】:2014-06-15 12:34:50
【问题描述】:

我正在使用 jQuery mobile 和 html5。我想在 webview 中包含我的页面 DIstance2.html,但它显示为 html 页面,而不是 jQuery 移动页面。这是我在 Android 中使用 webview 的代码,我的 jQuery mobile 版本是 1.4.1 和 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;
    }
}

【问题讨论】:

    标签: java javascript android jquery jquery-mobile


    【解决方案1】:

    在您的项目中添加一个资产文件夹并从那里调用您的 html url,例如 wvSite.loadUrl("file:///android_asset/dream-html5/api/Distance2html.html")

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-10
      • 2013-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-11
      • 2015-09-06
      • 1970-01-01
      相关资源
      最近更新 更多