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?
Asked
Active
Viewed 749 times
-2
-
try out my code, i have attached related xml code too. – Ram Koti Mar 15 '17 at 05:00
-
Google it you can find 100 of result, instead of asking question – CrazyMind Mar 15 '17 at 05:05
2 Answers
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