I am working on an Android app. I need to show a website on a webview and on an alert dialog. The site is shown in the webview, but not in the alert dialog. This is my code so far:
WebView:
WebView myWebView = (WebView) v.findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.setWebViewClient(new WebViewClient());
myWebView.loadUrl("https://...ilov_merged.html");
Alert Dialog:
AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this,R.style.MyDialogTheme)
.setTitle("TERMS OF USE AND PRIVACY POLICY");
WebView wv = new WebView(RegisterActivity.this);
wv.loadUrl("https://...ilov_merged.html");
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
builder.setView(wv);
builder .setCancelable(false);
builder.setPositiveButton(R.string.accept,
new Dialog.OnClickListener() {
@Override
public void onClick(
DialogInterface dialogInterface, int i) {
// Mark this version as read.
checkBox.setChecked(true);
// Close dialog
dialogInterface.dismiss();
// Enable orientation changes based on
// device's sensor
}
})
.setNegativeButton(android.R.string.cancel,
new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
// Close the activity as they have declined
// the EULA
}
});
builder.create().show();
What is wrong in my code?
SCREENSHOT