Issue
I have Html content shows Collapse window. But this is not loaded in Android WebView Section.Is shows a white screen only.
My code for WebView is
WebView webView = (WebView) rootView.findViewById(R.id.webview);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setJavaScriptEnabled(true);
// webView.getSettings().setBuiltInZoomControls(true);
// webView.setInitialScale(1);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.setWebChromeClient(new WebChromeClient());
webView.getSettings().setSupportMultipleWindows(true);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
title="<head><link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\">"+
"<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js\"></script>"+
"<script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js\"></script></head>";
title= title+"<div class=\"panel-group\" id=\"accordion\"><div class=\"panel panel-default\"><div class=\"panel-heading\"><h4 class=\"panel-title\">" +
"<a data-toggle=\"collapse\" data-parent=\"#accordion\" href=\"#collapseOne\">1. What is HTML?</a></h4></div><div id=\"collapseOne\" class=\"panel-collapse collapse in\"><div class=\"panel-body\">" +
"<p>HTML stands for HyperText Markup Language. HTML is the standard markup language for describing the structure of web pages. <a href=\"https://www.tutorialrepublic.com/html-tutorial/\" target=\"_blank\">Learn more.</a></p>" +
" </div></div></div></div>";
webView.loadData(title, "text/html;", "");
The screen shot in web is look like
Solution
The answer is already explained in here
just replace the loaddata function with
webview.loadDataWithBaseURL(null,title,"text/html", "utf-8", null);
Answered By - JITHIN GOPAL
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.