Android WebView相关知识(全)
来源:互联网 发布:java中final修饰的类 编辑:程序博客网 时间:2024/05/21 10:48
WebView教程
基本使用
webview=(WebView)findViewById(R.id.webview); //设置WebView属性,能够执行JavaScript脚本 webview.getSettings().setJavaScriptEnabled(true); //加载URL内容 webview.loadUrl("http://www.baidu.com"); //设置web视图客户端 webview.setWebViewClient(new MyWebViewClient()); webview.loadUrl("file:///android_asset/guide.html");//加载assets资源文件里的html //web视图客户端 public class MyWebViewClient extends WebViewClient{ public boolean shouldOverviewUrlLoading(WebView view,String url){ view.loadUrl(url); return true; }
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"><WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent"/></LinearLayout>
清楚缓存
// clear the cache before time numDays private int clearCacheFolder(File dir, long numDays) { int deletedFiles = 0; if (dir!= null && dir.isDirectory()) { try { for (File child:dir.listFiles()) { if (child.isDirectory()) { deletedFiles += clearCacheFolder(child, numDays); } if (child.lastModified() < numDays) { if (child.delete()) { deletedFiles++; } } } } catch(Exception e) { e.printStackTrace(); } } return deletedFiles; }//优先使用缓存:WebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //不使用缓存:WebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
//在退出应用的时候加上如下代码 File file = CacheManager.getCacheFileBaseDir(); if (file != null && file.exists() && file.isDirectory()) { for (File item : file.listFiles()) { item.delete(); } file.delete(); } context.deleteDatabase("webview.db"); context.deleteDatabase("webviewCache.db");
显示webView加载进度
<span style="font-size:14px;"> webview.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { //Activity和Webview根据加载程度决定进度条的进度大小 //当加载到100%的时候 进度条自动消失 context.setProgress(progress * 100); } }); </span>
2.webview学习记录http://www.apkbus.com/android-44567-1-1.html3.Android中使用WebView, WebChromeClient和WebViewClient加载网页http://www.apkbus.com/android-20053-1-1.html4.Android WebView开发常见问题http://www.apkbus.com/android-13095-1-1.html5.Android开发过程中有关WebView开发问题集锦http://www.apkbus.com/android-16190-1-1.html6.android webView 使用方法http://www.apkbus.com/android-20436-1-1.html7.Android官方文档在WebView中构建Web Appshttp://www.apkbus.com/android-20751-1-1.html8.Webview开发常用知识点http://www.apkbus.com/android-43956-1-1.html9.Android 控件之WebViewhttp://www.apkbus.com/android-1352-1-1.html10.WebView使用中遇到的一些问题&解决http://www.apkbus.com/android-14541-1-1.html11.Android 浅谈webview中的Javascripthttp://www.apkbus.com/android-6209-1-1.html12.android开发之WebView使用Javascript详解http://www.apkbus.com/android-16191-1-1.html13.第二十九讲:WebView学习指南http://www.apkbus.com/android-1114-1-1.html14.Webview在实际开发中比较实用资料http://www.apkbus.com/android-51717-1-1.html
二、WebView简单应用
1.网络视图 WebViewhttp://www.apkbus.com/android-985-1-1.html2.Android WebView删除缓存http://www.apkbus.com/android-21006-1-1.html3.WebView使用http://www.apkbus.com/android-4872-1-1.html4.WebView的使用心得与范例http://www.apkbus.com/android-18646-1-1.html5.WebView使用总结(应用函数与JS函数互相调用)http://www.apkbus.com/android-17219-1-1.html6.Android学习之利用WebView打开网页http://www.apkbus.com/android-20188-1-1.html7.Android webview下载歌曲(一)http://www.apkbus.com/android-2976-1-1.html
三、WebView实例源码
1.android WebView设置setInitialScale(...)后,修改设置的值,问题解决http://www.apkbus.com/android-45063-1-1.html2.Android中WebView和JavaScript进行简单通信http://www.apkbus.com/android-18803-1-1.html3..webview 实现翻页功能http://www.apkbus.com/android-51714-1-1.html
四、高级
缓存处理
http://www.open-open.com/lib/view/open1392188052301.html
0 0
- Android WebView相关知识(全)
- android webView相关知识
- android 最全 图片相关知识整理
- WebView相关知识
- webview相关的知识
- WebView相关知识
- webview相关知识
- WebView相关知识整理
- android webview 全解
- android WebView知识
- Android: WebView知识总结
- Android WebView 相关属性
- Android WebView相关属性
- android webView相关知识点
- Android WebView相关属性
- Android WebView相关属性
- Android WebView 相关
- android WebView 相关问题
- Javascript中关于类型转换的一些问题
- IOS常用第三方框架 --- SVProgressHUD 提示效果
- spring mvc Interceptor
- Python学习笔记(一)
- 学习Emmet的笔记
- Android WebView相关知识(全)
- sqlite数据库中第一条数据查不出来!
- 在线文档预览
- V4L2用户空间和kernel层driver的交互过程
- 识别常见编码格式文件并转换成UTF-8编码的java实现
- Spring Security hello world example
- IEEEtran参考文献乱码
- 关于Fragment嵌套Fragment中onActivityforresult无法调用的解决
- IOS常用第三方框架 --- ZAActivityBar 提示效果