Androidではパスワード入力ボックスの貼り付け・コピーは禁止されています
2206 ワード
setLongClickable(false); // setTextIsSelectable(false); //
/** * Called when a context menu option for the text view is selected. Currently
* this will be one of {@link android.R.id#selectAll}, {@link android.R.id#cut},
* {@link android.R.id#copy}, {@link android.R.id#paste} or {@link android.R.id#shareText}.
* @return true if the context menu item action was performed.
*/
public boolean onTextContextMenuItem(int id){
…………………………
switch (id) {
case ID_SELECT_ALL:
selectAllText();
return true;
case ID_UNDO:
if (mEditor != null) {
mEditor.undo();
}
return true; // Returns true even if nothing was undone.
case ID_REDO:
if (mEditor != null) {
mEditor.redo();
}
return true; // Returns true even if nothing was undone.
case ID_PASTE:
paste(min, max, true /* withFormatting */);
return true;
case ID_PASTE_AS_PLAIN_TEXT:
paste(min, max, false /* withFormatting */);
return true;
case ID_CUT:
setPrimaryClip(ClipData.newPlainText(null, getTransformedText(min, max)));
deleteText_internal(min, max);
return true;
case ID_COPY:
setPrimaryClip(ClipData.newPlainText(null, getTransformedText(min, max)));
stopTextActionMode();
return true;
case ID_REPLACE:
if (mEditor != null) {
mEditor.replace();
}
return true;
case ID_SHARE:
shareSelectedText();
return true;
}
return false;
}
EditText TextView, onTextContextMenuItem(int id) , ,
@Override
public boolean onTextContextMenuItem(int id) {
if (id == android.R.id.paste) {
return false;
}
return super.onTextContextMenuItem(id);
} `