Android开发:用webview做的浏览器怎么用两个文本框分别显示当前网页标题和地址?
展开全部
这里就假设你的标题文本框是TextView titleTextView, 地址文本框是TextView urlTextView。
//设置WebChromeClient来接受网页加载后得到的标题,然后设置给title
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onReceivedTitle(WebView view, String title){
super.onReceivedTitle(view, title);
titleTextView.setText(title);
}
}
)
//设置WebViewClient来获取网页url
webView.setWebViewClient(new HelpClient(){
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
urlTextView.setText(url);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询