Recently, I 've concentrated on reading the relevant chapters on the graphic user interface of Android Program Design (Beijing hang Publishing House), focusing on the basic knowledge of Android GUI in my favorite UI field.
The webview control provides an embedded browser to display local HTML or web pages.
Step 1 // main. xml
<WebView android:id="@+id/html" android:layout_width="fill_parent" android:layout_height="280px"/>
Step 2. // main class. Java
@ Overridepublic void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); webview web = (webview) findviewbyid(r.id.html); web. getsettings (). setjavascriptenabled (true); // used to support javascriptweb. loadurl ("http://www.baidu.com"); // access an external URL
Step 3. // androidmanifest. xml
If this row is not permitted, the webpage cannot be found when accessing the external website. This license is also required when writing socket communication programs.
</application> <uses-permission android:name="android.permission.INTERNET"/>
Step 4. // main class. Java
The browser view displayed by default in the normal webview control does not have a webpage loading progress bar or announcement. After clicking the hyperlink on the first page, the system will call its own browser process for next network access, this is not in line with our programming and usage habits. You can customize the operations by rewriting the following methods.
// This method can handle some Web operations when webview is loaded and loaded. setwebchromeclient (New webchromeclient () {@ overridepublic void onprogresschanged (webview view, int newprogress) {If (newprogress = 100) {// set the title of the activity, // You can also perform other operations based on your needs. settitle ("loaded");} else {settitle ("loading ....... ") ;}}}); web. setwebviewclient (New webviewclient () {@ overridepublic Boolean shouldoverrideurlloading (webview view, string URL) {// rewrite this method to indicate that clicking the link in the webpage is still redirected in the current webview, do not jump to view in the browser. loadurl (URL); Return true ;}
The school is about to begin. Three main roads are taught in the canteen, and the young faces are as young as we were two years ago.
At that time, I was still naive and always fantasized about the countless possibilities of the future.
Gradually, we all know that any possibility needs to be realized through our own efforts.
Good, bad, all by yourself.
What life looks like, in fact, they all draw a stroke with a paint brush.
No one can make me a bright future, but I can.