android2.1之后版本
其一:
(已运行成功 )
ClipboardManager clip = (ClipboardM anager)getSystemService(Context.CLIPB OARD_SERVICE);
clip.getText();
// 粘贴
clip.setText(str);
// 复制其二:
ClipboardM anager c= (ClipboardManager)getSyste mService(CLIPBOARD_SERVICE);
c.setTex t(smsContent.getText());
设置
Clipboard 的内容
c.getText(smsContent.getText());
提取clipboard的内容
android2.1之前版 本
IClipboard clip = IClipboard.Stub.asIn terface(ServiceManager.getService("clip board"));
clip.getClipboardText().toString ();
//获得复制的内容 clip.setClipboardTex t(text);
//设置Clipboard 的内容
====================================================================
========================================================================
例子:复制;
public void onClick(View arg0) {// 拷贝功能ClipboardManager clip = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE); clip.setText(Expression.number + "");// 提示信息Toast.makeText(MainActivity.this, "Copy Successful !", Toast.LENGTH_SHORT).show();show();}