I want to enable standard copy paste for a TextView (the same as for EditText). How can I do it?
I tried using a non-editable EditText but it didn't work well (sometimes it became editable or the copy paste overlay was not shown). And it's probably not a good approach generally.
Need a working solution starting at API 7.
Solution for theme full screen without
ActionBar
Extend
TextView
and in constructor paste following codeuse theme
or
set TextView in xml
see result
This works for copy pre-Honeycomb:
In xml textview paste this code
Then in java file,
Requirement : Need to copy and paste the text which is in the textview.
OutCome : Using textview , once i clicked the textview. Its automatically copied the text which is in the textview.
Note: While importing clipboardmanager try to prefer
Please prefer text clipboard manager
try to avoid content clipboard manager
For an
EditText
, in manifest inside the activity useandroid:windowSoftInputMode="adjustResize"
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
android:textIsSelectable="true"
In your Java class write this line to set it programmatically.
myTextView.setTextIsSelectable(true);
And long press on the TextView you can see copy/paste action bar.