的WebView不应用正确加载 [英] webview not loading correctly in application

查看:126
本文介绍了的WebView不应用正确加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有上有个标签控件的应用程序。其中一个标签加载网页视图对我来说,这是不正确加载。当我只是我的手机浏览器加载相同的地址,它加载的罚款。这里是code为我使用的WebView

I have an application that has a tab widget in it. One of the tabs loads a webview for me and it is not loading correctly. when i load the same address in just my phone browser it loads fine. here is the code for the webview i'm using

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class Sermons extends Activity {
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    WebView webview = new WebView(this);
    setContentView(webview);

 // Simplest usage: note that an exception will NOT be thrown
    // if there is an error loading this page (see below).
    webview.loadUrl("http://canyonculberts.com/ucc/?page_id=93");
    webview.getSettings().setBuiltInZoomControls(true);
    webview.setInitialScale(1);
    webview.getSettings().setAppCacheEnabled(false);

}
}

任何人有什么我可以做不同的这个,使其正常工作有什么想法?感谢您的帮助。

anyone have any thoughts on what i can do different on this to make it work correctly? Thank you for any help

推荐答案

首先,你需要android.permission.INTERNET对许可。

First, you need android.permission.INTERNET permission.

二,你可能需要setJavaScriptEnabled(真)来设置,并在最后做使用loadURL。

Second, you may need setJavaScriptEnabled(true) to settings, and do loadUrl at the very last.

webview.getSettings().setBuiltInZoomControls(true);
webview.setInitialScale(1);
webview.getSettings().setAppCacheEnabled(false);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://canyonculberts.com/ucc/?page_id=93");

这篇关于的WebView不应用正确加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆