如何在android中显示网页? [英] How to display a webpage in android?
本文介绍了如何在android中显示网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我运行该应用程序,则需要直接打开一个网页. 不使用单个组件.
I need to open a webpage directly if i run the app. Without using a single a component in it.
推荐答案
以下是直接打开google.com的Activity的onCreate方法:
Here is onCreate method of an Activity that opens google.com directly:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browser);
WebView wb = (WebView) findViewById(R.id.webView1);
wb.loadUrl("http://www.google.com.tr");
}
这是activity_browser.xml布局文件:
and here is the activity_browser.xml layout file:
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".BrowserActivity"
android:id="@+id/webView1" >
</WebView>
别忘了将Internet权限添加到AndroidManifest.xml文件:
Don't forget to add the internet permission to AndroidManifest.xml file:
<uses-permission android:name="android.permission.INTERNET" />
这篇关于如何在android中显示网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文