views:

33

answers:

1

Using WebViewClient and/or the WebChromeClient you can get a listener for when the page has loaded, however this is sometimes called before the WebView has any content in it, before it has displayed anything.

What would be a efficient method for determining when the WebView has displayed it's content?

Edit: (Trying to be more clear)

When I load a page in a WebView, I want to set the scroll to a specific position. It seems that the scroll position cannot be set until the page is loaded and it has an actual content height. So, I have tried two different approaches to determining when the page has finished loading, onPageFinished() from the WebViewClient and also onProgressChanged() from the WebChromeClient. Both of these tell me when the page has finished loading.

However, the problem is that sometimes it is called before the page has been displayed and therefore the page has no height and the scroll call does nothing.

I am trying to find a solid way to determine when the page is ready to be scrolled, ie. when it has its content height.

I imagine I could setup a checking loop after it finished loading to keep looking for when the height is available but that seemed like quite the hack. Hoping there is a cleaner way.

A: 
onLoadResource(WebView view, String url)

Notify the host application that the WebView will load the resource specified by the given url.

Still not clear of what the objective is here, but you might try

public void doUpdateVisitedHistory (WebView view, String url, boolean isReload)

I would "assume" that the page has completed loading before it is added to history...

Aaron Saunders
Thanks for the reply but doesn't that just tell the app when the specific resource is about to begin loading not when it has just been displayed? onLoadResource is called for each resource on the on page, these are all called before onPageFinished. What I am looking for is something that would be called after onPageFinished, right after the page has actually be displayed to the user.
littleFluffyKitty