Reputation: 3830
I applied this code for Textview Selection
android:textIsSelectable="true"
its working Great for selecting and copying Text. but there is a problem I don't want cut and paste option on texview in other words i want to make my textview only readonly so that it only give permission of copy not cut or edit it.
Upvotes: 1
Views: 517
Reputation: 54204
This is speculation, but it is somewhat informed speculation.
TextView
defines two methods that are potentially useful here: onCreateContextMenu(ContextMenu menu)
and onTextContextMenuItem(int id)
.
You could create a subclass of TextView
and override onCreateContextMenu()
to remove the cut option:
@Override
protected void onCreateContextMenu(ContextMenu menu) {
super.onCreateContextMenu();
menu.removeItem(android.R.id.cut);
}
Or you could create a subclass of TextView
and override onTextContextMenuItem()
to ignore the cut option:
@Override
public boolean onTextContextMenuItem(int id) {
if (id == android.R.id.cut) {
return true;
}
return super.onTextContextMenuItem(id);
}
Upvotes: 4