Webview In Alert Dialog Not Showing Content
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:
Solution 1:
Have you tried enabling javascript on the webview in your alertdialog? The page may not load without it, and your first approach enables it whilst your second doesn't. Since the URL has been removed, can't rule it out!
Additionally, I've experienced similar webview problems previously that were resolved by creating a new XML layout with just a webview inside, then inflating that for use:
WebView webView = LayoutInflater.from(activity).inflate(R.layout.webview_fragment, null) as WebView
webView.loadUrl("file:///android_asset/terms-register.html")
AlertDialog.Builder(activity).setView(webView)
webview_fragment.xml
:
<?xml version="1.0" encoding="utf-8"?><WebViewxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/web_view"android:layout_width="match_parent"android:layout_height="match_parent"android:theme="@style/VerticalScrollbar" />
Post a Comment for "Webview In Alert Dialog Not Showing Content"