I struggle with android EditText
for days, try to get rid of the "paste" popup when select text. (my extend EditText is readonly and selectable).
from the anwser to the question : EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event
override the package-private method canPaste()
is ok for dalvik runtime, but will not work with the android 5.0 above using ART.
So I find other way to solve the problem, not overide the method, but try replace Editor's field variable
I look the EditText
's helper class Editor
got a lot specific logic, looks if I can replace InsertionPointCursorController
in a proper time by a dummy subclass, it will not show the popup. (InsertionPointCursorController is a private class, it implement a private interface, so to replace it with a dummy subclass, I need to extend the class or implement the interface)
public boolean performLongClick(boolean handled) {
// Long press in empty space moves cursor and shows the Paste affordance if available.
if (!handled && !isPositionOnText(mLastDownPositionX, mLastDownPositionY) &&
mInsertionControllerEnabled) {
final int offset = mTextView.getOffsetForPosition(mLastDownPositionX,
mLastDownPositionY);
stopSelectionActionMode();
Selection.setSelection((Spannable) mTextView.getText(), offset);
getInsertionController().showWithActionPopup();
handled = true;
}
looks the getInsertionController().showWithActionPopup(); show the popup :(
Now I'll go to try replace remove callback for an anternative