I have a TextView that launches a context menu:
textView.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
@Override
public void onCreateContextMenu(ContextMenu contextMenu,
View view,
ContextMenu.ContextMenuInfo contextMenuInfo) {
// Do stuff...
}
});
This textview also has the android:autoLink="all"
attribute set in its XML.
Now, if I set the contents of the TextView to a URL and long press over the URL, the context menu appears first, but when I lift my finger the link is pressed and opens the browser.
Is there any way to have the context menu or the long press consume the touch event so that the link is not clicked? I have considered overriding onTouch()
for the TextView to handle ACTION_UP events, but I cannot reliably keep track of when the context menu is visible to block the touch event.