I'm building an Android app and I want to copy the text value of an EditText widget. It's possible for the user to press Menu+A
then Menu+C
to copy the value, but how would I do this programatically?
|
http://developer.android.com/reference/android/content/ClipboardManager.html Use ClipBoardManager's setText method:
|
|||||||||||
|
So everyone agree on how this should be done, but since no one want to give a complete solution, here goes:
I assume you have something like following declared in manifest:
|
|||||||||||||
|
Googling brings you to android.content.ClipboardManager and you could decide, as I did, that Clipboard is not available on API < 11, because the documentation page says "Since: API Level 11". There are actually two classes, second one extending the first - android.text.ClipboardManager and android.content.ClipboardManager. android.text.ClipboardManager is existing since API 1, but it works only with text content. android.content.ClipboardManager is the preferred way to work with clipboard, but it's not available on API Level < 11 (Honeycomb). To get any of them you need the following code:
But for API < 11 you have to import |
||||
|
you can try this.. |
|||||
|