你能告诉我如何在android中删除webview中的缓存吗?我在一个文本字段中打开一个url,因为我在该字段上写了come文本,然后转到下一页。然后在同一页面上写了将打开autosuggest的相同内容(例如我之前使用过的文本)。
谢谢
这是我的代码
package com.firstgroup.ui;
import android.os.Bundle;
import android.app.Activity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class ApplicationLoad extends Activity {
WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.app);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.setWebViewClient(new MyBrowser());
mWebView.getSettings().setLoadsImagesAutomatically(true);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
mWebView.getSettings().setAppCacheEnabled(false);
mWebView.loadUrl("http://192.168.11.90/loginuser/login");
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(event.getAction() == KeyEvent.ACTION_DOWN){
switch(keyCode)
{
case KeyEvent.KEYCODE_BACK:
if(mWebView.canGoBack() == true){
mWebView.goBack();
}else{
finish();
}
return true;
}
}
return super.onKeyDown(keyCode, event);
}
private class MyBrowser extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".ApplicationLoad" >
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>
尝试以下Webview方法,
mWebView.clearFormData();
mWebView.clearCache(true);
要删除EditText的边框,您需要在.xml文件中声明以下属性。
android:background="@null"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句