Android Browse the Web

Source: Internet
Author: User

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4A/2E/wKioL1Qjtm3CHPWPAAEJyRaAG04153.jpg "title=" ZBFJNB %g_[{5gg (' a06l%b0.jpg ' alt= "wkiol1qjtm3chpwpaaejyraag04153.jpg"/>

1. Write the interface

<webview

Android:id= "@+id/webview"

Android:layout_width= "Match_parent"

android:layout_height= "Match_parent"/>


2. Permission to apply


<uses-permission android:name= "Android.permission.INTERNET"/>


3, Mainactivity.java


Package Com.malakana.webview;


Import Android.os.Bundle;

Import Android.annotation.SuppressLint;

Import android.app.Activity;

Import Android.webkit.WebView;

Import android.webkit.WebViewClient;


public class Mainactivity extends Activity {


@SuppressLint ("setjavascriptenabled")

@Override

protected void OnCreate (Bundle savedinstancestate) {

Super.oncreate (savedinstancestate);

Setcontentview (R.layout.activity_main);

WebView WebView = (WebView) Findviewbyid (R.id.webview);

Webview.getsettings (). Setjavascriptenabled (True); Enable JavaScript

Webview.setwebviewclient (New Webviewclientdemo ());

Webview.loadurl ("http://www.sina.com.cn"); Loading Web pages

Webview.loadurl ("http://www.nuc.edu.cn/");

}

Private class Webviewclientdemo extends Webviewclient

{

public boolean shouldoverrideurlloading (WebView view,string URL)

{

View.loadurl (URL); Browse Web pages in WebView instead of invoking a system browser

return true;

}

}

}


Android Browse the Web

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.