-2

I am new to android .I am trying to develop an android application which has web view opening when clicked on a specific button.I need to show the website which has java script.How can I create it?

Androbot
  • 64
  • 9

2 Answers2

2

I think you can include this in your java inside your onclick

  web.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        return super.shouldOverrideUrlLoading(view, url);
    }
});
Nazim ch
  • 834
  • 8
  • 20
1

try in your xml:

<WebView
    android:id="@+id/web_view"
    android:visibility="gone"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:id="@+id/button"/>

in your java file:

final Button button = (Button)findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            button.setVisibility(View.GONE);
            webview.setVisibility(View.VISIBLE);
            private WebView webView;
            webView = (WebView) findViewById(R.id.web_view);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.loadUrl("http://google.com");
        }
    });`
Ram Koti
  • 2,203
  • 7
  • 26
  • 36