I have a set of AlertDialog's which I can go back and forth. Dialog A, Dialog B(has HTML content) and Dialog C. On dialog B I have added a web view to show some HTML content, I want to disable keyboard from popping up on this perticular dialog B. HTML content does not have any edit text's. I have used "getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)" which does the job the first time the dialog is opened. When I navigate for the first time from dialog A to dialog B, dialog B does not pop up the keyboard. When I come back to dialog B from A or C the keyboard starts popping up when i swipe on the HTML content.
HTML content is a touch based content.
I am assuming that the code for hiding keyboard is not executed every time the dialog is opened.
I have tried "SOFT_INPUT_STATE_ALWAYS_HIDDEN" and "SOFT_INPUT_STATE_HIDDEN".
EDIT : If I opened google on the web view which has a text field for search. key board does not popup when I touch the edit text which is good even though i navigate. But when I try to scroll up and down on the page the keyboard pops up and disappears(Happens from the second visit to the dialog).
Could you please share your thoughts on how to hide the keyboard every time I open this dialog B.
@Override
@Deprecated
protected Dialog onCreateDialog(int id) {
AlertDialog.Builder builder = new AlertDialog.Builder(this,R.style.AlertDialogCustom);
final Boolean pinVerficationDialogPopedUp = loginData.getBoolean("pinVerficationDialogPopedUp",
false);
if (pinVerficationDialogPopedUp == false) {
switch (id) {
case DIALOG_ADD_A_PERSON_BODY_MAP:
try {
LayoutInflater inflaterBodyMap = this
.getLayoutInflater();
final View inflatorBodyMap = inflaterBodyMap
.inflate(
R.layout.dialog_incident_window_body_map,
null);
bodyMapWebView = (WebView) inflatorBodyMap.findViewById(R.id.webView);
bodyMapWebView.getSettings().setJavaScriptEnabled(true);
bodyMapWebView.getSettings().setBuiltInZoomControls(true);
bodyMapWebView.getSettings().setSupportZoom(true);
/*
Trying to resolve issue where sometimes when the HTML page loads, it does
not load the whole content
*/
bodyMapWebView.post(new Runnable() {
@Override
public void run() {
bodyMapWebView.loadUrl("file:///android_asset/bodyMap.html");
}
});
bodyMapWebView.addJavascriptInterface(new WebAppInterface(this), "Android");
builder.setTitle("Injured person");
builder.setView(inflatorBodyMap);
builder.setPositiveButton("Next",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
//next dialog
}
});
builder.setNegativeButton("Back",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
//previous dialog
}
});
alertBodyMap = builder.create();
alertBodyMap.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
alertBodyMap.show();
return dialog;
} catch (Exception e) {
e.printStackTrace();
}
}
}
return dialog
}
Your help much appreciated. Thank you