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 programmatically?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
To enable the standard copy/paste for TextView, U can choose one of the following:
Change in layout file: add below property to your TextView
In your Java class write this line two set the grammatically.
myTextView.setTextIsSelectable(true);
And long press on the TextView you can see copy/paste action bar.
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
android.text.ClipboardManager
and for API >= 11android.content.ClipboardManager
And import
import android.content.ClipboardManager;