When I am doing a picture station, I want to pack the 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:
OnCreate (Bundle savedinstancestate) { Super. OnCreate (savedinstancestate); WebView webview=WebView (this); Webview.loadurl ("http://www.mimi199.com/"); Intent intent= getintent (); Setcontentview (WebView); }
Get
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
webviewclient { shouldoverrideurlloading (WebView webview,string url) { webview.loadurl (url ) ;//This is the sentence, so that each hyperlink is opened in the app's WebView, not the browser return True;} }
and change the mainactivity a little bit.
OnCreate (Bundle savedinstancestate) { Super. OnCreate (savedinstancestate); WebView webview=WebView (this); Webview.loadurl ("http://www.mimi199.com/");
Plus this sentence will be able to webview.setwebviewclient (Mywebviewclient ()); }
Android Beginner with everyone
Android uses WebView to load Web page problems