Simple copy-and-paste functionality is available in Android. The code is simple.
Code to copy text:
Clipboardmanager cbm= (Clipboardmanager) mainactivity.this . Getsystemservice (Context.clipboard_service);
Code to paste text:
Clipboardmanager paste = (clipboardmanager) mainactivity.this . Getsystemservice (Context.clipboard_service);
However, after API11, there is a difference between the copy and paste, in fact, is the problem of the guide package, details see http://www.apkbus.com/android-174549-1-1.html
Here, stick to the original.
【
In the previous project to do a copy and paste functionality, but after api11 copy paste is a difference, and the online are only a part of, now share to everyone;
public void OnClick (View v) {
TODO auto-generated Method Stub
Switch (V.getid ()) {
Case R.id.top_back:
Finish ();
Break
Case R.id.btn_invited_copy:
int sdkint = Build.VERSION.SDK_INT;
if (Sdkint > Build.version_codes. Honeycomb) {//Api11
Clipboardmanager copy = (Clipboardmanager) actmyinvitationcode.this
. Getsystemservice (Context.clipboard_service);
Copy.settext (Invitationcode);
Toast.maketext (Actmyinvitationcode.this, "invitation code successfully copied to Pasteboard",
Toast.length_short). Show ();
} else if (Sdkint <= build.version_codes. Honeycomb) {
Android.text.ClipboardManager Copyq = (android.text.ClipboardManager) actmyinvitationcode.this
. Getsystemservice (Context.clipboard_service);
Copyq.settext (Invitationcode);
Toast.maketext (Actmyinvitationcode.this, "invitation code successfully copied to Pasteboard",
Toast.length_short). Show ();
}
Break
}
}
Some children's shoes have not yet seen the difference in API 11 after the use of Android.content.ClipboardManager, and before the api11 used is android.text.ClipboardManager;
】
Copy and paste of Android text