android - Opening a Web View -


I have an image button, when clicked, opens a new activity with the web view. The web view will display some custom HTML. When I click the button the web view does not show anything.

This is the code for my button view: -

  Public Zero GoToContact (see view) {WebView webView; SetContentView (R.layout.webview); Webview = (webview) Find VVBIID (RIDMMView); WebView.getSettings () setJavaScriptEnabled (true). String custom HTML = " gt;  gt; & lt; h1 & gt; Hello, webview & lt; / h1 & gt; & lt; / body & gt; & lt; / html & Gt; "; WebView.loadData (customHtml, "text / html", "UTF-8"); }   

This is my web view layout: -

  Android: Lineline Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: Orientation = "Horizontal" & gt; & Lt; Android: layout_height = "60dp" Android: Content Circles = "@String": Android: id = "@ + id / GoToHome" Android: onClick = "GoToTC" Android: background = "@ drawable / test" Android: layout_width = "360dp" / Header "/> & Lt; WebView Android: id = "@ + id / myWebView" Android: layout_width = "match_parent" Android: layout_height = "400dp" /> & Lt; / LinearLayout & gt;    

try this

  public class MainActivity activity Extension of {personal button button; Public Zero OnCreate (Bundle savedInstanceState) {Final reference reference = this; Super.onCreate (savedInstanceState); SetContentView (R.layout.main); Button = (button) Find VVBID (RID button url); Button.setOnClickListener (New OnClickListener) {@Override Public Zero onClick (see arg0) {intent = new intent (reference, WebViewActivity.class); startActivity;)}}; }} Public class enhances WebViewActivity activity {Private WebView webView; Crate on Public Zero (Bundle Saved Instantstate) {Super. Secret (Saved Instantstate); SetContentView (R.layout.webview); Webview = (webview) find VVBIID (R. WEBV1); WebView.getSettings () setJavaScriptEnabled (true). WebView.loadUrl ("http://www.google.com"); }}    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -