user5520878
user5520878

Reputation:

Webview not loading in android

I have a webview and "Submit" button in my android app. Webview loads a url, and on clicking submit button both submit button and webview are hidden revealing a textview and "Go" button..

in submit button's onClickListener I have removed the webview as follows.

    submit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {  
            webview.setVisibility(View.GONE);   
            submit.setVisibility(View.GONE);
            mytextview.setVisibility(View.VISIBLE);
            go.setVisibility(View.VISIBLE);
        }
    }

This works fine..

In my go button's onClickListener I am loading the new url for this webview as follows

    submit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {  
                            webview.setWebViewClient(new WebViewClient());
                            webView.getSettings().setJavaScriptEnabled(true);
            webview.setVisibility(View.VISIBLE);
            mytextview.setVisibility(View.GONE);
            webview.loadUrl("http://www.example.com");
        }
    }

Here textview disappears but it's not loading the webview. Only a blank screen appears...

Is it anything missing in my code..

Upvotes: 2

Views: 105

Answers (1)

Pavandroid
Pavandroid

Reputation: 1586

Can you try keeping the below two lines.

webview.setWebViewClient(new WebViewClient());
webView.getSettings().setJavaScriptEnabled(true);`

I believe this will fix your issue.

Upvotes: 1

Related Questions