有人可以给出一个 android 中 webview 实现的确切例子吗
Hi I am developing android application using WebView
implementation.
I followed the official android tutorial.
I am not getting errors when building my project in eclipse, but when running the application :
the application has stopped working unexpectedly
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
您的 Java 文件应如下所示:
您的 xml 文件应如下所示:
在清单中的
之后使用以下内容:Your Java file should be like this:
Your xml file should be like this:
Use the following in your manifest after
<uses-sdk><uses-sdk/>
:Android WebView示例
WebView 用于在我们的应用程序中显示网页。让我们创建一个 WebView 并加载任何
中提供权限的网站
在 AndroidManifest.XML activity_main.xml
MainActivity.Java
Android WebView Example
WebView used to show webpages in our app. Let's make a WebView and load any website
provide permission in AndroidManifest.XML
activity_main.xml
MainActivity.Java
开始吧:
将此代码放入您的 onCreate-Method 中。
并且不要忘记在 Android Manifest 中设置 Permission Internet。
Here you go:
Put this code in your onCreate-Method.
And don't forget to set the Permission Internet in Android Manifest.
WebView 是在应用程序内显示网页的视图。您还可以指定 HTML 字符串,并可以使用 WebView 在应用程序中显示它。
教程示例:http://www.viralandroid。 com/2015/09/android-webview-tutorial-with-examples.html
Activity_main.xml 文件
MainActivity.java 文件
WebView is a view that display web pages inside your application. You can also specify HTML string and can show it inside your application using WebView.
Tutorial with Example: http://www.viralandroid.com/2015/09/android-webview-tutorial-with-examples.html
activity_main.xml file
MainActivity.java File
xml文件
java文件
Xml file
java file
现在在 onCreate() 上使用此类
Now use this class on onCreate() like
除了@ghost回答之外,如果您希望您的网络视图像浏览器一样功能齐全,即您可以前进和后退,那么您需要覆盖您的活动的 onBackPressed 方法,如下所示
In addition to @ghost answer, if you want your web-view to be fully functional like a browser i.e. you can go forward and back then you need to override onBackPressed method of your activity like below
您必须
You must