Sunny
Sunny

Reputation: 1076

calling web view client from dialog not executing

My application is to creating web views dynamically, also setting dynamically created web views width, height and x,y positions. I am setting the width, height,x,y positions and calling the web view client on custom dialog . But the web view client not calling. when i tried without using the web view client the specified url loads in the default browser. But my main requirement is to re-size the web view and loading it in my activity. When running the program web view showing with white color but the url not loading also the web client and should override method not calling. My codes are given below

try
{
    wv[tmpm].getSettings().setJavaScriptEnabled(true);
    wv[tmpm].setWebViewClient(new Myweb());
    //wv[tmpm].setWebViewClient(new Myweb);
    //wv[tmpm].loadUrl(url);
}
Myweb class given below

private class Myweb extends WebViewClient
{
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        Log.d("In extends webview client","HIiiiiiiiiiiiiiii");
        view.loadUrl(url);
        return true;};
    }
}

the log in shouldoverrideUrl not showing in logcat, also when i touch the web view i got the error "Should not happen: no rect-based-test nodes found" in log cat. Pls help me. Thanks in advance.

Upvotes: 1

Views: 193

Answers (1)

Sunny
Sunny

Reputation: 1076

i solved myself........ correct code given below..

 try

   {

      wv[tmpm].setWebViewClient(new WebViewClient());
      wv[tmpm].requestFocus();
      wv[tmpm].getSettings().setJavaScriptEnabled(true);
      wv[tmpm].loadUrl(url);
   }

Myweb class given below

 private class Myweb extends WebViewClient
     {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            try
            {
                Log.d("In extends webview client","HIiiiiiiiiiiiiiii");
                view.loadUrl(url);
            }
            catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }
            return true;

        }
        @Override
        public void onPageFinished(WebView view, String url) {
            try {

            } catch (Exception we) {
                we.printStackTrace();
            }
            super.onPageFinished(view, url);
        }

     }  

Upvotes: 3

Related Questions