When webview opens HTML files with frameset tags, they are often not displayed completely. Only the last page is displayed.
You can simply set it.
Overwrite shouldoverrideurlloading and return false;
Mwebview. setwebviewclient (New webviewclient (){
@ Override
Public Boolean shouldoverrideurlloading (webview view, string URL ){
Return false; // false indicates frameset. True indicates no frameset.
}
}
The Code is as follows:
Package CN. HPC. cai. webview; import android. OS. bundle; import android. app. activity; import android. graphics. bitmap; import android. view. menu; import android. view. view; import android. webKit. webview; import android. webKit. webviewclient; import android. widget. toast; public class mainactivity extends activity {@ overrideprotected void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcon Tentview (R. layout. activity_main); Init () ;}@ overridepublic Boolean oncreateoptionsmenu (menu) {// inflate the menu; this adds items to the action bar if it is present. getmenuinflater (). inflate (R. menu. activity_main, menu); Return true;} private webview mwebview; private void Init () {mwebview = (webview) findviewbyid (R. id. web_view); mwebview. setwebviewclient (New webviewclient () {@ override public boo Lean shouldoverrideurlloading (webview view, string URL) {toast. maketext (mainactivity. this, "shouldoverrideurlloading" + URL, toast. length_short ). show (); Return false; // false: Display frameset; true: Do not display frameset} @ override public void onpagestarted (webview view, string URL, bitmap favicon) {// callback when page Jump exists} @ override public void onpagefinished (webview view, string URL) {// callback after page Jump ends} @ override public v Oid onreceivederror (webview view, int errorcode, string description, string failingurl) {toast. maketext (mainactivity. This, "Oh no! "+ Description, toast. length_short ). show () ;}}); // string url = "<HTML> <frameset Cols = \" 25%, 25% \ "frameborder = No framespacing = 0 border = 0> <frame src = \" file: /// sdcard/demo.html "// +" \ "/> <frame src = \" file: /// sdcard/left.htm \ "/> </frameset>
Layout file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="@string/hello_world" /> <WebView android:id="@+id/web_view" android:layout_width="fill_parent" android:layout_height="fill_parent" /></LinearLayout>