我正在使用 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;
}
}
最佳答案
在您的项目中添加一个 asset 文件夹并从那里调用您的 html url,例如 wvSite.loadUrl("file:///android_asset/dream-html5/api/Distance2html.html")
关于java - jQuery Mobile 无法在 WebView 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23366918/