- Attribute für Rechtschreibprüfung, automatische Vervollständigung und automatische Korrektur auf „false“ setzen über JavaScript.
- Verwendung einer JavaScript-Schnittstelle zur Steuerung des Tastaturverhaltens, wenn Boolean fokussiert ist.
Code: Select all
webView.addJavascriptInterface(new Object() {
@JavascriptInterface
public void onMessage(String message) {
try {
JSONObject jsonObject = new JSONObject(message);
boolean focused = jsonObject.getBoolean("focused");
if (focused) {
// Set the input type to visible password
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(webView, InputMethodManager.SHOW_IMPLICIT);
webView.postDelayed(() -> {
webView.evaluateJavascript("document.activeElement.setAttribute('type', 'text');", null);
}, 100);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, "Android");
Mein Ziel ist es, das zu verwenden textVisiblePassword-Funktion, die wir normalerweise in Android XML EditText für WebView haben, wenn Textfelder wie contenteditables fokussiert sind.