1
我有一個活動A它有一個按鈕。點擊此按鈕後,活動B啓動。活動B在xml佈局中包含WebView,該佈局加載本地存儲在設備上的HTML頁面。整個網頁由幾個CSS(重物)和jsons(大)組成。這時RAM的使用量大約爲90MB。 HTML中包含文本和數字的輸入字段。問題是打開和關閉webview 3-4次後,當我點擊輸入字段的鍵盤變得不可見。Android鍵盤隱形
這是我的活動代碼。
public class LaunchActivity extends Activity {
WebView webView;
private final int FILECHOOSER_RESULTCODE = 1;
private Uri mCapturedImageURI = null;
public String mCameraPhotoPath;
String webViewUrl;
public String mMediaType;
public int flag = 0;
public File imageStorageDir;
Bundle bundle;
String mode;
public ProgressDialog progDailog;
int questionToBeLaunch;
Project project;
public void onBackPressed() {
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.launch_survey);
// getting data from intent and creating the url to load.
webView = (WebView) findViewById(R.id.webView1);
setWebViewProperties();
Map<String, String> header = new HashMap<String, String>(2);
header.put("Pragma", "no-cache");
header.put("Cache-Control", "no-cache");
webView.loadUrl(webViewUrl, header);
}
public void setWebViewProperties(){
JavaScriptInterface jsInterface = new JavaScriptInterface(this);
// Javascript enabled on webview
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
webView.addJavascriptInterface(jsInterface, "interface");
// Other webview options
webView.getSettings().setLoadWithOverviewMode(true);
//webView.getSettings().setUseWideViewPort(true);
//Other webview settings
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(false);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAllowFileAccessFromFileURLs(true);
webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
webView.getSettings().setSupportZoom(true);
progDailog = new ProgressDialog(LaunchSurvey.this);
//Load url in webview
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
progDailog.setMessage("Loading...");
progDailog.setCanceledOnTouchOutside(false);
progDailog.setCancelable(false);
progDailog.show();
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
webView.clearCache(true);
}
});
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
// webView.setOnTouchListener(null);
webView.removeAllViews();
webView.clearCache(true);
webView.clearHistory();
// clearCache(getApplicationContext());
webView.destroy();
webView = null;
}
}
我有同樣的問題,遍佈網絡搜索,嘗試了不同的東西,但沒有任何工作。 –
你能分享你的代碼,特別是你爲webview編寫的代碼嗎? –