/*系統通過光標獲取對象*/
View view = ((Activity)mContext).getCurrentFocus();
if(viewCopy instanceof EditText){//判斷是不是EditText
EditText edit = (EditText) view;
int start = edit.getSelectionStart();
int end = edit.getSelectionEnd();
if(start>end){//因爲光標選取EditText中內容時可能會從不同方向(左右)開始選取,讀取內容時從光標起始位置開始讀取的
start = start+end;
end = start -end;
start = start-end;
}
String select = edit.getText().toString().substring(start,end);
clipboard.setText(select);//放到剪貼板
}