Android Webview不显示网页中的小部件

时间:2019-11-07 11:55:40

标签: webview

美好的一天

任何帮助将不胜感激。我正在尝试在android中创建一个webview应用程序,但收到以下错误错误:无法从静态上下文引用非静态方法setJavaScriptEnabled(boolean)...

我的代码是...

package com.vmedia.demo_2;

import androidx.appcompat.app.AppCompatActivity;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends AppCompatActivity {

WebView webView;
private String webUrl = "https://atumtrading.co.za/orders";
WebView myWebView = (WebView) findViewById(R.id.myWebView);
WebSettings.setJavaScriptEnabled(true);



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_main);



    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

    });
}

@Override
public void onBackPressed() {
    if (webView.canGoBack()){
        webView.goBack();
    }
    else
        super.onBackPressed();
}

}

0 个答案:

没有答案