ios&&android复制剪贴板

ios剪贴板

UIPasteboard*pasteboard = [UIPasteboard generalPasteboard];

pasteboard.string=self.label.text;

android剪贴板


import android.content.ClipData;

import android.content.ClipboardManager;

//************************Clipboard 剪贴板*********************************************************

//复制

@SuppressWarnings("deprecation")

public void SetClipboard(String text)

{

ClipboardManager cm = (ClipboardManager) getSystemService(this.CLIPBOARD_SERVICE);

//    cm.setText(text);

ClipData mClipData = ClipData.newPlainText("Label", text);

cm.setPrimaryClip(mClipData);

}

//粘贴

public String GetClipboard()

{

String data="";

ClipboardManager cm = (ClipboardManager) getSystemService(this.CLIPBOARD_SERVICE);

//    CharSequence cs= cm.getText();

//    data= cs.toString();

ClipData mClipData = cm.getPrimaryClip();

data=mClipData.getItemAt(0).getText().toString();

return data;

}

你可能感兴趣的:(ios&&android复制剪贴板)