简体   繁体   English

如何检测 webview 中单个视图页面的更改标题

[英]How detect change title of single view page in webview

I have a text view on my view so I want to change it based on the title of the web page.我的视图中有一个文本视图,因此我想根据网页的标题对其进行更改。 when the page loaded the first time I get the title from omPageFinished method of WebViewClient, but after that when the single view page change (for example loaded new page without reloading webview) how get the new title of the new page?当页面第一次加载时,我从 WebViewClient 的 omPageFinished 方法获取标题,但之后当单个视图页面更改时(例如加载新页面而不重新加载 webview)如何获取新页面的新标题?

             override fun onPageFinished(view: WebView?, url: String?) {
                super.onPageFinished(view, url)
                toolbar_title.text = view.title
            }

You can use below code:您可以使用以下代码:

 mWebView.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onReceivedTitle(WebView view, String title) {
                super.onReceivedTitle(view, title);
                cardTitle.setText(title);
             }

    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM