I'm doing a picture station http://www.mimi199.com to pack its mobile station into an app,
I used WebView to load the Web (I wanted to use PhoneGap to do it, but it was too much trouble),
The specific code is as follows:
protected void OnCreate (Bundle savedinstancestate) {
super.oncreate (savedinstancestate);
WebView webview=new WebView (this);
Webview.loadurl ("http://www.mimi199.com/");
Intent intent= getintent ();
Setcontentview (webView);
}
done
Wait, home effect is good, but there is a problem, when clicked on a hyperlink, the app will automatically call the browser to open a new page, this is not the function I want, I want to open the time should be every page in the app open, close browser God horse!
looked up a lot of information, there is a webviewclient class
just write another class to be webviewclient.
The code is as follows
Public class Mywebviewclient extends Webviewclient {
Public Boolean shouldoverrideurlloading (WebView webview,string url) {
webview.loadurl (URL);//This is the phrase, let each hyperlink in the app's WebView open, not the browser
return true;
}
}
and change the mainactivity a little bit .
protected void OnCreate (Bundle savedinstancestate) {
super.oncreate (savedinstancestate);
WebView webview=new WebView (this);
Webview.loadurl ("http://www.mimi199.com/");
//Multiple plus this sentence will be all right
webview.setwebviewclient (New Mywebviewclient ());
}
Android Beginner with everyone
This article is from the "Yang Technical column" blog, please be sure to keep this source http://13438626.blog.51cto.com/13428626/1980440
Android uses WebView to load Web page problems