Android Webview - XML?

Is there any way to define webview in xml layout, not in code.

And if so, how? Or is it recommended that it be encoded as activity?

+4
source share
3 answers

Yes, as stated above, use the WebView tag:

<WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="50dip"/> 

An example application can be found here: http://www.androiddom.com/2011/04/creating-android-calculator-tutorial.html

The author creates a calculator that uses the WebView, which is listed in the main.xml layout.

+9
source

Yes, use the <WebView /> to do this in the xml layout.

0
source

and in your code type:

 WebView wv = (WebView)findViewById(R.id.webview); wv.setWebViewClient(new WebViewClient(){ public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); wv.loadUrl("your url here"); 
0
source

All Articles