【发布时间】:2017-06-20 14:03:17
【问题描述】:
我在一个应用程序中有几个 webviews,其中一个根本没有加载,但是当在特定 webview 中更改为一个简单的 url 时,比如“https://www.google.com/”,它可以正确加载。我要加载的网址是“https://mpi.mashie.eu/public/menu/v%C3%A4ster%C3%A5s+stad+skola/a4ec46b2?country=se”,这是一个午餐菜单,位于应用程序内部的 web 视图中,如代码和屏幕截图所示。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lunch);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
lunch_view = (WebView)findViewById(R.id.webLunch);
lunch_view.getSettings().setJavaScriptEnabled(true);
lunch_view.setWebViewClient(new WebViewClient());
lunch_view.loadUrl("https://mpi.mashie.eu/public/menu/v%C3%A4ster%C3%A5s+stad+skola/a4ec46b2?country=se");
}
带有 Webview 的 Android Studio 布局文件
我在这里测试了类似问题的答案: Android webview not loading url
【问题讨论】: