[英]simplest way to load android webview
what is the simplest way to load android webview? 加载android webview最简单的方法是什么?
I have already specified webview in the activity layout, how can i load a website on it while running the emulator. 我已经在活动布局中指定了webview,如何在运行模拟器时加载网站。 I have had many problems with resources not identified and the main_activity.out.xml files have been giving me troubles.
我遇到了许多未识别资源的问题,而main_activity.out.xml文件给我带来了麻烦。 A simple webview to load a webpage would be nice.
加载网页的简单webview会很不错。
... ...
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
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). 您正在获取
main_activity.out.xml
因为您正在尝试编译Xml文件(main_activity.out.xml具有焦点并且您单击了运行)。 In general if this error happens you have to 通常,如果发生此错误,则必须执行此操作
to load WebView you have to declare your webview component in your xml 要加载WebView,您必须在xml中声明webview组件
<WebView
android:id="@+id/myWebView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
and then in your activity in onCreate() method call 然后在你的活动中onCreate()方法调用
// get reference to your view
WebView webview = (WebView)findViewById(R.id.myWebView);
// load your WebView content
webview.loadUrl("http://google.com/");
Simplest way? 最简单的方法?
Get access to WebView via 通过访问WebView
WebView webview = (WebView)findViewById(R.id.webView1);
webview.loadUrl("http://stackoverflow.com/");
Greets Flo Greets Flo
main_activity.out.xml has been created maybe beacuse you pressed the run button on Eclipse while your main_activity.xml was opened. main_activity.out.xml已创建,可能是因为您在打开main_activity.xml时按下了Eclipse上的运行按钮。 Eclipse tryed to compile your xml and not your application.
Eclipse尝试编译你的xml而不是你的应用程序。
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: 为了最好地管理你的android项目中的webview,只需阅读文档:
http://developer.android.com/guide/webapps/webview.html http://developer.android.com/guide/webapps/webview.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.