获取系统CLIPBOARD_SERVICE服务 得到copy实例 就搞定了
private class ClickListenerImpl implements OnClickListener {
@Override
public void onClick(View v) {
switch (v.getId()) {
//复制
case R.id.button:
ClipboardManager copy = (ClipboardManager) MainActivity.this
.getSystemService(Context.CLIPBOARD_SERVICE);
copy.setText("呵呵哒");
break;
//粘贴
case R.id.textView:
ClipboardManager paste = (ClipboardManager) MainActivity.this
.getSystemService(Context.CLIPBOARD_SERVICE);
String content=paste.getText().toString().trim();
mTextView.setText(content);
break;
default:
break;
}
}
}