标签:
简单的页面跳转
package com.example.webview; import android.support.v7.app.ActionBarActivity; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.webkit.WebView; public class MainActivity extends Activity { private String url = "http://2014.qq.com/"; private WebView webView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.web); /* * Uri uri = Uri.parse(url); // url为你要的链接
* Intent intent = new Intent(Intent.ACTION_VIEW, uri);
* startActivity(intent); */ init(); } //需要获取网络权限, 在manifest中加<uses-permission android:name="android.permission.INTERNET"/>
private void init() { // TODO Auto-generated method stub webView = (WebView) findViewById(R.id.web); // webView加载本地资源 // webView.loadUrl("file:///android_asset/1.html"); // webView加载web资源 webView.loadUrl("http://www.baidu.com"); } }
web.xml文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <WebView android:id="@+id/web" android:layout_width="match_parent" android:layout_height="match_parent"/> </LinearLayout>
标签:
原文地址:http://www.cnblogs.com/yi-mi-yangguang/p/5851005.html