• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

"Can't resolve symbol 'mywebview'"

Mekaboo

Lurker
Jul 8, 2022
7
3
Hey all:giggle:

Adding Webview to my app since I have website already made but getting the error above within my MainActivity.java page. All of the xml file are coded fine its just this problem. Can anyone help? Thank ya!!!

Code:
private Webview mywebview;

@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("Google");
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
}
public class mywebClient extends WebViewClient {
@override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view,url,favicon);
}
@override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
@override
public void onBackPressed() {
if (mywebView.canGoBack()) {
mywebView.goBack();
} else {
super.onBackPressed();
}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones