0

I face to this problem: I've a WebView name webViewA which loaded a website, and now I want clone the webViewA to a webViewB which contains all content is loaded from webViewA, how can I do that?

Thank you! EDIT:

Ok, I'll explain my purpose, I use the android-flip to make a FlipView of WebView, at the start, my WebView will load a url, then, when user flip to next page, I want to use this webview and scrollTo next page position. With android-flip, I cannot return the WebView which load data before in the getView method, so I think I should clone that WebView and use the clone, scroll and return to flipview.

Han Tran
  • 2,073
  • 4
  • 22
  • 37
  • Why not call the same URL? – Edward van Raak Mar 28 '13 at 08:21
  • http://stackoverflow.com/questions/2376471/how-do-i-get-the-web-page-contents-from-a-webview – waqaslam Mar 28 '13 at 08:24
  • @EdwardvanRaak Because it'll cost time to load that URL again :) Waqas Checking it :) – Han Tran Mar 28 '13 at 08:30
  • may you please explain, how and what exactly you want to achieve by 'cloning' the webview, may be we can find a solution if we clarify the problem further? – Darpan Mar 28 '13 at 08:36
  • @Darpan I've edit my question, please check it :) – Han Tran Mar 28 '13 at 08:58
  • You can try using multiple WebViews? Load new page in a new WebView, and when go back just show the old WebView. So nothing will be changed on the old page, even can still run some js in the background. – Aloong Mar 28 '13 at 09:03
  • @Aloong I used to think so but it'll be cost memory and not good :( and if use multiple webview, I cannot scroll the page to next position! – Han Tran Mar 28 '13 at 09:06
  • I'm using multiple WebView in my app and if you can control the content of the page not being to large(simple html and js you wrote, not any external complex web page), the memory cost will be acceptable. – Aloong Mar 28 '13 at 09:14
  • @Aloong But in the getView of flipview the scrollTo not work :) If you try it, you will see :( – Han Tran Mar 28 '13 at 09:19
  • Can you try loading javascript into the webview as a url to scroll the webpage instead of scrolling the view? – Aloong Mar 28 '13 at 09:23
  • Yeah, but still not work: mWeb.loadUrl("javascript:window.scrollBy(0,1000)"); – Han Tran Mar 28 '13 at 09:34

1 Answers1

0

You should be able to make a request to retrieve the html in the background. Once you have the html you can store it. Then you can use this stored html to load the same contents into as many web views as you like. Without having to make a network request.

Voski
  • 139
  • 2
  • 4