1、首先屏蔽 EditText 的软键盘

 2、EditText在光标下插入删除内容

  

clear.setOnClickListener(new OnClickListener() {   
@Override
public void onClick(View v) {
int start = newPassword.getSelectionStart();
int end = newPassword.getSelectionEnd();
Toast.makeText(SetPasswordActivity.this, start+"-----"+end, Toast.LENGTH_LONG).show();
if(start-1!=0){
newPassword.getText().delete(start-1, end);
}else{
newPassword.getText().clear();
}
}
});

3、EditText光标移动

      Selection.setSelection(newPassword.getText(),newPassword.getText().length());

4、复制操作

ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);

clipboard.setText("Text to copy");

 

String data = clipboard.getText();

 

boolean isData = clipboard.hasText();