i'm facing a unusual problem while loading a webview with new content.
Imagine a ebook reader app that im going to implement...
app that allows the user to swap(fling) the screen backward and forward to see the chapter content(nothing but reading the book).
Book that contains several chapters and i'm keeping each chapter in separate webpage
when activity begins i load the first chapter in to the webview.
i'm loading a new chapter as soon as one ch开发者_如何学JAVAapter ends (user is unaware of loading new page to web view he is just turning pages forward and backward)
after first chapter 2,3,4 ..n chapters..
As going next chapter i need to allow the user to come to previous chapter.
in some condtion imagine if user finishes chapter 1 and come to chapter 2 . but user may want refer back to previous page. Then i should load the chapter 1.
i can do that by loading previous chapter. but the content that is visible to user should not be the beginning of the chapter it should be end of the chapter. So im scrolling up to end of chapter see the end of below code. But logic not working ..
public void fling(...){ //swap forward if (end_of_page==false) scrollBy(480); else if (end_of_page==true) webview.Load(); //load next chapter //swap backward if beginning_of_chapter==true && previous_chapter_exists==true webview.Load(); //load previous chapter scrollBy(10000); //Scroll up to 10000 px so that i can get end of chapter
But Problem here is the webview will not scrolls upto 10000px. bcoz the statement scrollBy(10000); executes before the previous chapter is loaded into webview (i.e bcoz of delay in webview loading).
How can i solve this problem?
Use onPageFinished to do processing after the page is loaded.
精彩评论