Apart from just loading url, you can have more control over your WebView by using the methods defined in WebView class. They are listed as follows −
| Sr.No | Method & Description |
|---|---|
| 1 |
canGoBack()
This method specifies the WebView has a back history item.
|
| 2 |
canGoForward()
This method specifies the WebView has a forward history item.
|
| 3 |
clearHistory()
This method will clear the WebView forward and backward history.
|
| 4 |
destroy()
This method destroy the internal state of WebView.
|
| 5 |
findAllAsync(String find)
This method find all instances of string and highlight them.
|
| 6 |
getProgress()
This method gets the progress of the current page.
|
| 7 |
getTitle()
This method return the title of the current page.
|
| 8 |
getUrl()
This method return the url of the current page.
|
If you click on any link inside the webpage of the WebView, that page will not be loaded inside your WebView. In order to do that you need to extend your class from WebViewClient and override its method. Its syntax is −
private class MyBrowser extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }
Comments
Post a Comment