作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在尝试几种方法,其中一些在这里找到,在我的应用程序中使用 webview 加载 url,但到目前为止,对于来自客户端的一个特定页面,所有这些方法都没有成功。让我们以这种方法为例:
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/background">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="@drawable/top_heading"
android:id="@+id/rlayout1">
<TextView android:layout_width="wrap_content"
android:layout_centerVertical="true" android:layout_centerHorizontal="true"
android:textColor="#ffffff" android:textSize="22dip"
android:textStyle="bold" android:layout_height="wrap_content"
android:text="More Information" android:id="@+id/txtviewfbdisplaytitle" />
</RelativeLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_below="@+id/rlayout1"
android:id="@+id/rlayout2">
<WebView android:id="@+id/webview1" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0" />
</RelativeLayout>
</RelativeLayout>
MainActivity.Java
public class MainActivity extends Activity {
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
Button btnBack;
WebView webview;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webview=(WebView)findViewById(R.id.webview1);
webview.setWebViewClient(new MyWebViewClient());
openURL();
}
/** Opens the URL in a browser */
private void openURL() {
webview.loadUrl("[see solution]");
webview.requestFocus();
}
}
虽然其他网站可以工作,但这个网站却不行。我对 Android 编程相当陌生。接下来我可以尝试什么?
附带问题:URL 有什么不同的作用来阻止成功加载?
最佳答案
该网站使用 DOM 存储来运行,并且由于默认情况下 DOM 存储在 android webview
中处于禁用状态,因此您必须启用它。
webview.setWebViewClient(new MyWebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDomStorageEnabled(true);
openURL();
关于java - 无法在 webview 中加载 url - 黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54097683/
我正在开发一个需要能够平均三个数字的 Facebook 应用程序。但是,它总是返回 0 作为答案。这是我的代码: $y = 100; $n = 250; $m = 300; $number = ($y
我只是无法弄清楚这一点,也找不到任何对我来说有意义的类似问题。我的问题:我从数据库中提取记录,并在我的网页上以每个面板 12 条的倍数显示它们。因此,我需要知道有多少个面板可以使用 JavaScrip
我是一名优秀的程序员,十分优秀!