Copy and paste of Android text

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.