开发者

how to display current webview in android

I have 3 webviews displaying query result for a search string from 3 search engines.. if google is displayed, i have yahoo and ask buttons at the bottom....when I click either of them, I get results for the entered query...

                    if(btn2.getText()=="Yahoo")
        {
            wv2.loadUrl("http://search.yahoo.com/bin/search?p="+value);
            vf.setDisplayedChild(1);
            System.out.println("Yahoo is working开发者_运维百科");
            btn1.setText("Ask");
            btn2.setText("Google");
        }

        else if(btn2.getText()=="Ask")
        {
            wv3.loadUrl("http://www.ask.com/web?q="+value);
            vf.setDisplayedChild(2);
            System.out.println("Ask is working");
            btn1.setText("Google");
            btn2.setText("Yahoo");
        }
        else if(btn2.getText()=="Google")
        {   
            wv1.loadUrl("http://www.google.com/search?q="+value);
            vf.setDisplayedChild(0);
            System.out.println("Google is working");
            btn1.setText("Yahoo");
            btn2.setText("Ask");
        }   

With the above code, each time i press the buttons at the bottom, I am getting query results regenerated,,,,I want to display the result if i select any.... For ex: Google results displayed the search string "FACEBOOK" and i selected first result in that....Suppose I select Yahoo button at the bottom, then yahoo is displayed and I have a google button formed at the bottom....when I click that google button, I want the first result that I selected previously...Kindly suggest what changes to make in the above code


Use this method:

webview.getURL() on each button click.and get url that in string and just load that in that url in webview.

I would just mention here take relevant webview for that method means as for Yahoo may you take webview1 like this.


why using 3 webviews. cant you do all that stuff in 1 webview. and if you are using 3 different webviews then what is the need of loading url again and again simply make rest of the 2 webviews invisible when showing any 1 result(just mmake present 1 visible.).

Thanks....


ok rashmi do 1 thing.......
make 3 string variables...

latestGoogleURL...,  
latestAskURL...,  
latestYahooURL..., 

now whenever u click some result update these URL in corresponding search result..
ex.. if u click first face book result from google than save bthe URL of first facebook result in latestGoogleURL...,

and when you load them load these URL on button click as follows

 wv1.loadUrl(latestGoogleResult);  

Thanks...


You can try Web View tutorial and WebView class documentation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜