android:使用webview加载网页
16lz
2021-01-23
android使用webview加载网页
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | package com.example.webview; import android.os.Bundle; import android.annotation.SuppressLint; import android.app.Activity; import android.view.KeyEvent; import android.view.Menu; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends Activity { private WebView webview; @SuppressLint( "SetJavaScriptEnabled" ) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); webview = (WebView) findViewById(R.id.webview); WebSettings webSettings = webview.getSettings(); //设置WebView属性,能够执行Javascript脚本 webSettings.setJavaScriptEnabled( true ); //设置可以访问文件 webSettings.setAllowFileAccess( true ); //设置支持缩放 webSettings.setBuiltInZoomControls( true ); //加载需要显示的网页 webview.loadUrl( " |
xml代码
1 2 3 4 5 6 7 8 9 10 11 12 | <?xml version= "1.0" encoding= "utf-8" ?> |
更多相关文章
- android 播放视频保存的一些网页
- android view视图的层叠(叠加)
- Android 从网页中跳转到APP
- Android WebView访问SSL证书网页(onReceivedSslError)
- android mtk6732 camera otp 加载流程
- Android 9.0及以上WebView无法打开网页 ERR_CLEARTEXT_NOT_PERMI
- Android点击WebView网页中的email发送邮件调用
- Android 视图动画(View Animation) 使用详解