-3

I'm trying to load web page inside of webview.the webview load inside the Dialog.i'm tried this code.but show the error builder (android.content.context) in builder cannot be applied to .. and underline this in red line.

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    webview=(WebView)findViewById(R.id.webview);
    webview.setWebViewClient(new WebViewClient();
    webview.loadUrl("http://example.com/abc.html");
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setView(webview);
    dialog.setPositiveButton("Okay", null);
    dialog.show();
}
Yash
  • 49
  • 1
  • 2
  • 8

1 Answers1

0

Try This->

WebView webView = new WebView(this);
webView.loadUrl("http://www.google.com/");
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setView(webView);
dialog.setPositiveButton("Okay", null);
dialog.show();

Check This Too--> android: webview inside dialog or popup

Community
  • 1
  • 1
Chaudhary Amar
  • 836
  • 8
  • 20