android.webkit.WebView#loadData ( )源码实例Demo

下面列出了android.webkit.WebView#loadData ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: edslite   文件: VersionHistory.java
@Override
public void onCreate(Bundle savedInstanceState)
{
	Util.setTheme(this);
	super.onCreate(savedInstanceState);
	setContentView(R.layout.changes_dialog);
	//setStyle(STYLE_NO_TITLE, R.style.Dialog);
	markAsRead();
	WebView vw = findViewById(R.id.changesWebView);
	vw.loadData(getString(R.string.changes_text), "text/html; charset=UTF-8", null);
	//vw.setBackgroundColor(0);
	//Spanned sp = Html.fromHtml( getString(R.string.promo_text));
	//((TextView)v.findViewById(R.id.promoTextView)).setText(sp);
	//tv.setText(sp);
	//((TextView)v.findViewById(R.id.promoTextView)).setText(Html.fromHtml(getString(R.string.promo_text)));
	findViewById(R.id.okButton).setOnClickListener(v -> finish());
}
 
源代码2 项目: android-test   文件: SimpleWebViewActivity.java
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  WebView mainWebView = new WebView(this);
  setContentView(mainWebView);
  mainWebView.loadData(
      "<html>" +
      "<script>document.was_clicked = false</script>" +
      "<body> " +
      "<button style='height:1000px;width:1000px;' onclick='document.was_clicked = true'> " +
      "I'm a button</button>" +
      "</body> " +
      "</html>", "text/html", null);
  WebSettings settings = mainWebView.getSettings();
  settings.setJavaScriptEnabled(true);
}
 
源代码3 项目: utexas-utilities   文件: DataUsageActivity.java
@Subscribe
public void openWebView(OpenWebViewEvent ev) {
    WebView wv = new WebView(this);
    wv.getSettings().setJavaScriptEnabled(true);
    wv.setWebViewClient(new DataUsageWebViewClient());
    wv.addJavascriptInterface(new JsInterface(), "ututilities");
    wv.loadData(ev.html, "text/html; charset=UTF-8", null);
}
 
源代码4 项目: magpi-android   文件: IssueDetailsFragment.java
public void updateIssueView(final Issue issue) {
    this.issue = issue;
    TextView issueText = (TextView) getActivity().findViewById(R.id.article);
    issueText.setText(issue.getTitle() + " - " + issue.getDate());
    String htmlArticle = "<img align='left' src='%s' style='margin-right:10px; height:120px; width:90px;'/>%s";
    WebView editorialText = (WebView) getSherlockActivity().findViewById(R.id.text_editorial);
    String content = issue.getEditorial().replace("\r\n", "<br/>").replace("\u00a0", " ");
    editorialText.loadData(String.format(htmlArticle, issue.getCoverUrl(), content), "text/html; charset=utf-8", "utf-8");
    editorialText.setVisibility(View.VISIBLE);
    getSherlockActivity().findViewById(R.id.web_content_progress).setVisibility(View.GONE);
}
 
源代码5 项目: Applozic-Android-SDK   文件: AlWebViewActivity.java
public void webViewClientPost(WebView webView, String url,
                              Collection<Map.Entry<String, String>> postData) {
    StringBuilder sb = new StringBuilder();

    sb.append("<html><head></head>");
    sb.append("<body onload='form1.submit()'>");
    sb.append(String.format("<form id='form1' action='%s' method='%s'>", url, "post"));

    for (Map.Entry<String, String> item : postData) {
        sb.append(String.format("<input name='%s' type='hidden' value='%s' />", item.getKey(), item.getValue()));
    }
    sb.append("</form></body></html>");

    webView.loadData(sb.toString(), "text/html", "utf-8");
}
 
源代码6 项目: opensudoku   文件: Changelog.java
private void showChangelogDialog() {

        String changelog = getChangelogFromResources();

        WebView webView = new WebView(mContext);
        webView.loadData(changelog, "text/html", "utf-8");

        AlertDialog changelogDialog = new AlertDialog.Builder(mContext)
                .setIcon(R.drawable.ic_info)
                .setTitle(R.string.what_is_new)
                .setView(webView)
                .setPositiveButton(R.string.close, null).create();

        changelogDialog.show();
    }
 
源代码7 项目: something.apk   文件: PreviewFragment.java
@Override
public void viewCreated(View frag, Bundle savedInstanceState) {
    threadView = (WebView) frag.findViewById(R.id.preview_webview);
    initWebview();
    // TODO: Change back to loadDataWithBaseURL, as it won't load the CSS without it.
    threadView.loadData(this.threadHtml, "text/html", "utf-8");
}
 
源代码8 项目: mimi-reader   文件: WebActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web);

    String html = getIntent().getStringExtra(EXTRA_HTML);

    WebView webView = findViewById(R.id.web_view);
    webView.loadData(html, "text/html; charset=UTF-8", null);
}
 
源代码9 项目: android-discourse   文件: ArticleActivity.java
@Override
public void finish() {
    // This is what you have to do to make it stop the flash player
    WebView webview = (WebView) findViewById(R.id.uv_webview);
    webview.loadData("", "text/html", "utf-8");
    super.finish();
}
 
源代码10 项目: RobotCA   文件: PageOneFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    View view = inflater.inflate(R.layout.pageone_fragment, container, false);

    WebView webView = (WebView) view.findViewById(R.id.setup_webview);
    webView.loadData(Utils.readText(getActivity(), R.raw.setup), "text/html", null);

    return view;
}
 
源代码11 项目: RobotCA   文件: AboutFragment.java
/**
 * Called when the activity is created.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    @SuppressLint("InflateParams") View view = inflater.inflate(R.layout.fragment_about, null);

    WebView webView = (WebView) view.findViewById(R.id.abouttxt);
    webView.loadData(Utils.readText(getActivity(), R.raw.about), "text/html", null);

    return view;
}
 
源代码12 项目: RobotCA   文件: PageThreeFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.pagethree_fragment, container, false);

    WebView webView = (WebView) view.findViewById(R.id.faq_webview);
    webView.loadData(Utils.readText(getActivity(), R.raw.faq), "text/html", null);

    return view;
}
 
protected void setupViews() {
    setupCustomSwipeRefreshLayout();
    WebView webView = (WebView) findViewById(R.id.webview);
    StringBuilder html = new StringBuilder("<html><body>");
    for (int i = 0; i < 20; i++)
        html.append("It's a WebView   It's a WebView   It's a WebView ");
    html.append("</body></html>");
    webView.loadData(html.toString(), "text/html", null);
}
 
源代码14 项目: ResearchStack   文件: ConsentDocumentStepLayout.java
private void initializeStep() {
    setOrientation(VERTICAL);
    LayoutInflater.from(getContext()).inflate(R.layout.rsb_step_layout_consent_doc, this, true);

    WebView pdfView = (WebView) findViewById(R.id.webview);
    pdfView.loadData(htmlContent, "text/html; charset=UTF-8", null);

    SubmitBar submitBar = (SubmitBar) findViewById(R.id.submit_bar);
    submitBar.setPositiveAction(v -> showDialog());
    submitBar.setNegativeAction(v -> callbacks.onCancelStep());
}
 
源代码15 项目: smartcoins-wallet   文件: ContactListAdapter.java
private void loadWebView(WebView webView, int size, String encryptText) {
    String htmlShareAccountName = "<html><head><style>body,html { margin:0; padding:0; text-align:center;}</style><meta name=viewport content=width=" + size + ",user-scalable=no/></head><body><canvas width=" + size + " height=" + size + " data-jdenticon-hash=" + encryptText + "></canvas><script src=https://cdn.jsdelivr.net/jdenticon/1.3.2/jdenticon.min.js async></script></body></html>";
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webView.loadData(htmlShareAccountName, "text/html", "UTF-8");
}
 
@ReactProp(name = "source")
public void setSource(WebView view, @NonNull ReadableMap source) {
    if (source != null) {
        if (source.hasKey("html")) {
            String html = source.getString("html");
            if (source.hasKey("baseUrl")) {
                view.loadDataWithBaseURL(
                        source.getString("baseUrl"), html, HTML_MIME_TYPE, HTML_ENCODING, null);
            } else {
                view.loadData(html, HTML_MIME_TYPE, HTML_ENCODING);
            }
            return;
        }
        if (source.hasKey("uri")) {
            String url = source.getString("uri");
            String previousUrl = view.getUrl();
            if (source.hasKey("method")) {
                String method = source.getString("method");
                if (method.equals(HTTP_METHOD_POST)) {
                    byte[] postData = null;
                    if (source.hasKey("body")) {
                        String body = source.getString("body");
                        try {
                            postData = body.getBytes("UTF-8");
                        } catch (UnsupportedEncodingException e) {
                            postData = body.getBytes();
                        }
                    }
                    if (postData == null) {
                        postData = new byte[0];
                    }
                    view.postUrl(url, postData);
                    return;
                }
            }
            HashMap<String, String> headerMap = new HashMap<>();
            if (source.hasKey("headers")) {
                ReadableMap headers = source.getMap("headers");
                ReadableMapKeySetIterator iter = headers.keySetIterator();
                while (iter.hasNextKey()) {
                    String key = iter.nextKey();
                    if ("user-agent".equals(key.toLowerCase(Locale.ENGLISH))) {
                        if (view.getSettings() != null) {
                            view.getSettings().setUserAgentString(headers.getString(key));
                        }
                    } else {
                        headerMap.put(key, headers.getString(key));
                    }
                }
            }
            view.loadUrl(url, headerMap);
            return;
        }
    }
    view.loadUrl(BLANK_URL);
}
 
源代码17 项目: iBeebo   文件: SettingChangeLogDialog.java
public void show() {
    // Get resources
    String _PackageName = fActivity.getPackageName();
    Resources _Resource;
    try {
        _Resource = fActivity.getPackageManager().getResourcesForApplication(_PackageName);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
        return;
    }

    // Get dialog title
    int _resID = _Resource.getIdentifier(TITLE_CHANGELOG, "string", _PackageName);
    String _Title = _Resource.getString(_resID);
    // _Title = _Title + " v" + GetAppVersion();

    // Get Changelog xml resource id
    _resID = _Resource.getIdentifier(CHANGELOG_XML, "xml", _PackageName);
    // Create html change log
    String _HTML = GetHTMLChangelog(_resID, _Resource);

    // Get button strings
    String _Close = _Resource.getString(R.string.changelog_close);

    // Check for empty changelog
    if (_HTML.equals("") == true) {
        // Could not load change log, message user and exit void
        Toast.makeText(fActivity, "Could not load change log", Toast.LENGTH_SHORT).show();
        return;
    }

    // Create webview and load html
    WebView _WebView = new WebView(fActivity);
    // _WebView.loadData(_HTML, "text/html", "UTF-8");
    _WebView.loadData(_HTML, "text/html; charset=UTF-8", null);

    AlertDialog.Builder builder = new AlertDialog.Builder(fActivity).setTitle(_Title).setView(_WebView)
            .setPositiveButton(_Close, new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                }
            });
    builder.create().show();
}
 
源代码18 项目: bitshares_wallet   文件: SendFragment.java
private void loadWebView(WebView webView, int size, String encryptText) {
    String htmlShareAccountName = "<html><head><style>body,html {margin:0; padding:0; text-align:center;}</style><meta name=viewport content=width=" + size + ",user-scalable=no/></head><body><canvas width=" + size + " height=" + size + " data-jdenticon-hash=" + encryptText + "></canvas><script src=https://cdn.jsdelivr.net/jdenticon/1.3.2/jdenticon.min.js async></script></body></html>";
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webView.loadData(htmlShareAccountName, "text/html", "UTF-8");
}
 
源代码19 项目: bitshares_wallet   文件: AboutActivity.java
private void loadWebView(WebView webView, int size, String encryptText) {
    String htmlShareAccountName = "<html><head><style>body,html { margin:0; padding:0; text-align:center;}</style><meta name=viewport content=width=" + size + ",user-scalable=no/></head><body><canvas width=" + size + " height=" + size + " data-jdenticon-hash=" + encryptText + "></canvas><script src=https://cdn.jsdelivr.net/jdenticon/1.3.2/jdenticon.min.js async></script></body></html>";
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webView.loadData(htmlShareAccountName, "text/html", "UTF-8");
}
 
源代码20 项目: RobotCA   文件: AboutFragmentRobotChooser.java
/**
 * Called when the activity is  created.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    @SuppressLint("InflateParams") View view = inflater.inflate(R.layout.fragment_about, null);

    WebView webView = (WebView) view.findViewById(R.id.abouttxt);
    webView.loadData(Utils.readText(getActivity(), R.raw.about), "text/html", null);

    return view;


}