2

I have a selectable textView with

textView.setTextIsSelectable(true)

I want to show my own popup menu on double tap and I want to show standart text selection controls on long tap. But now when I make double tap I see text selection action mode and then popup menu. How I can disable text selection mode on double tap?

I've tried to make textView selectable in onLongClickListener and then call performLongClick() - works only with second long tap, I don't need this

textView.setOnLongClickListener(new View.OnLongClickListener() {
    @Override
    public boolean onLongClick(View view) {
        textView.setTextIsSelectable(true);
        if (view.getTag() == null){
            view.setTag(new Object());
            view.performLongClick();
        }
        return false;
    }
});

Also tried call textView private method via reflection to show selection action mode - falls with java.lang.NoSuchFieldException: mEditor, I checked the sources and I see mEditor field

Field field = textView.getClass().getDeclaredField("mEditor");
field.setAccessible(true);
Object mEditor = field.gettextView);

Class c = Class.forName("android.widget.Editor");
Method method = c.getMethod("startSelectionActionMode", null);
method.setAccessible(true);
Object result = method.invoke(mEditor);

So, how I can disable text selection mode on double tap and show text selection only with long tap?

Georgy Gobozov
  • 13,633
  • 8
  • 72
  • 78
  • 4
    You can check this: http://stackoverflow.com/questions/21448833/catch-double-click-on-textview-android try overriding double tap to do nothing. – Oğuzhan Döngül Dec 28 '14 at 10:39
  • 1
    @oguzhand thanks buddy, that works, don't how I missed that! In my case I just need show popup in doubleTap and return true to consume event. – Georgy Gobozov Dec 28 '14 at 11:33

0 Answers0