Reputation: 707
what is the simplest way to load android webview?
I have already specified webview in the activity layout, how can i load a website on it while running the emulator. I have had many problems with resources not identified and the main_activity.out.xml files have been giving me troubles. A simple webview to load a webpage would be nice.
...
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
Upvotes: 1
Views: 1516
Reputation: 31466
You are getting main_activity.out.xml
because you are trying to compile Xml files (main_activity.out.xml have the focus and you clicked run). In general if this error happens you have to
to load WebView you have to declare your webview component in your xml
<WebView
android:id="@+id/myWebView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
and then in your activity in onCreate() method call
// get reference to your view
WebView webview = (WebView)findViewById(R.id.myWebView);
// load your WebView content
webview.loadUrl("http://google.com/");
Upvotes: 3
Reputation: 5326
main_activity.out.xml has been created maybe beacuse you pressed the run button on Eclipse while your main_activity.xml was opened. Eclipse tryed to compile your xml and not your application.
To do that right, try to select the reference of your application inside the project explorer on the left and then click the Run button.
In order to manage at best the webview in your android project, just read the documentation:
http://developer.android.com/guide/webapps/webview.html
Upvotes: 0
Reputation: 3259
Simplest way?
Get access to WebView via
WebView webview = (WebView)findViewById(R.id.webView1);
webview.loadUrl("http://stackoverflow.com/");
Greets Flo
Upvotes: 0