Use a custom input box in the interface to modify the transaction password
Similar to this (forgive me for being ugly~)
As a result, a user feedback yesterday appeared on the VIVO phone, and the Del key was invalid~~~
The final discovery is:EdiText's OnKeyListener
No response.
Finally, I searched and found the solution: RewriteInputConnectionWrapper for EdiTextView
The problem was solved after the method:
The code is as follows:
public class ZanyEditText extends EditText { private OnDelKeyEventListener delKeyEventListener; public ZanyEditText(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public ZanyEditText(Context context, AttributeSet attrs) { super(context, attrs); } public ZanyEditText(Context context) { super(context); } @Override public InputConnection onCreateInputConnection(EditorInfo outAttrs) { return new ZanyInputConnection((outAttrs), true); } private class ZanyInputConnection extends InputConnectionWrapper { public ZanyInputConnection(InputConnection target, boolean mutable) { super(target, mutable); } @Override public boolean sendKeyEvent(KeyEvent event) { if (() == KeyEvent.ACTION_DOWN && () == KeyEvent.KEYCODE_DEL) { if (delKeyEventListener != null) { (); return true; } } return (event); } @Override public boolean deleteSurroundingText(int beforeLength, int afterLength) { if (beforeLength == 1 && afterLength == 0) { return sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)) && sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL)); } return (beforeLength, afterLength); } } /** * * Function description: <br> * 〈Detailed Function Description〉 * * @param delKeyEventListener EditText delete callback */ public void setDelKeyEventListener(OnDelKeyEventListener delKeyEventListener) { = delKeyEventListener; } public interface OnDelKeyEventListener { void onDeleteClick(); } }
refer to:/questions/4886858/android-edittext-deletebackspace-key-event%22
The above is the reason and solution for the del key on VIVO mobile phone that I introduced to you and the reason why OnKeyListener is not responding. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!