Android EditText prohibits the copy and paste of the complete code. androidedittext
<! -- Define basic layout LinearLayout --> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: tools = "http://schemas.android.com/tools" android: layout_width = "match_parent" android: layout_height = "match_parent" android: paddingBottom = "@ dimen/activity_vertical_margin" android: paddingLeft = "@ dimen/plugin" android: paddingRight = "@ dimen/activity_horizontal_margin" android: paddin GTop = "@ dimen/activity_vertical_margin" android: orientation = "vertical"> <! -- Define the TextView control --> <EditText android: id = "@ + id/Et" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: text = "prohibit copy and paste" android: longClickable = "false"/> </LinearLayout>
Package com. example. yanlei. yl2; import android. content. clipboardManager; import android. OS. bundle; import android. support. v7.app. appCompatActivity; import android. view. actionMode; import android. view. menu; import android. view. menuItem; import android. widget. editText; public class MainActivity extends AppCompatActivity {EditText Et; @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); // call the onCreate method of the parent class // set the layout file of the current page to activity_main setContentView (R. layout. activity_main); Et = (EditText) findViewById (R. id. et); Et. setCustomSelectionActionModeCallback (new ActionMode. callback () {@ Override public boolean onPrepareActionMode (ActionMode mode, Menu menu) {return false;} @ Override public void onDestroyActionMode (ActionMode mode) {}@ Override public boolean onCreateActionMode (ActionMode mode, Menu menu) {return false ;}@ Override public boolean onActionItemClicked (ActionMode mode, MenuItem item) {return false ;}});}}