non-static method loadUrl(String) cannot be referenced from a static context

1.1k Views Asked by At
WebView.loadUrl(additionalData.optString("targeturl"));

how to debug error non-static method loadUrl(String) cannot be referenced from a static context

1

There are 1 best solutions below

0
On

The error is self explanatory, you should call loadUrl on an instance of WebView, it's not a static method, therefore you can't call it statically on the class like you're doing.

e.g.

WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.example.com");

also, check out the documentation