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 (some
use theme
@android:style/Theme.Black.NoTitleBar.Fullscreen
or
@android:style/Theme.WithActionBar
set TextView in xml
android:textIsSelectable="true"
see result
this is better:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
final android.content.ClipboardManager clipboardManager = (android.content.ClipboardManager) context
.getSystemService(Context.CLIPBOARD_SERVICE);
final android.content.ClipData clipData = android.content.ClipData
.newPlainText("text label", "text to clip");
clipboardManager.setPrimaryClip(clipData);
} else {
final android.text.ClipboardManager clipboardManager = (android.text.ClipboardManager) context
.getSystemService(Context.CLIPBOARD_SERVICE);
clipboardManager.setText("text to clip");
}
For an EditText
,
in manifest inside the activity use
android:windowSoftInputMode="adjustResize"