8种机械键盘轴体对比
本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?
http://ngudream.com/http://ngudream.com/
近来接到一个需求,就是 webview 要动态加载 css 文件,替换 html 文件原来的,达到定制界面的目的。自己做demo 试验证了一下,webview 本身提供这样的接口,可以达到要求。主要就是使用 webview 的 shouldInterceptRequest 接口,拦截请求。
拦截接口
WebView 调用 loadUrl 后,会首先根据传入的URL获取响应,然后再将响应显示到页面上。根据这个原理,我们可以在获取响应过程中重新改变请求URL或者直接将响应替换。要想拦截 WebView 加载网页我们必须重写 WebViewClient 类,在 WebViewClient 类中我们重写 shouldInterceptRequest() 方法。
通过查看 WebViewClient 的源码我们可以发现,有两个同名方法,分别是:/**
* Notify the host application of a resource request and allow the
* application to return the data. If the return value is null, the WebView
* will continue to load the resource as usual. Otherwise, the return
* response and data will be used. NOTE: This method is called on a thread
* other than the UI thread so clients should exercise caution
* when accessing private data or the view system.
*
* @param view The [email protected] android.webkit.WebView} that is requesting the
* resource.
* @param url The raw url of the resource.
* @return A [email protected] android.webkit.WebResourceResponse} containing the
* response information or null if the WebView should load the
* resource itself.
* @deprecated Use [email protected] #shouldInterceptRequest(WebView, WebResourceRequest)
* shouldInterceptRequest(WebView, WebResourceRequest)} instead.
*/
@Deprecated
public WebResourceResponse shouldInterceptRequest(WebView view,
String url) {
return null;
}
为了让每次加载 html 页面都能够回调 shouldInterceptRequest 函数