mob_web_dev
mob_web_dev

Reputation: 2362

How to hide text selection tool menu in double click?

We know that setTextIsSelectable() is used to select the text.So when we long press the text selection tool menu appear (copy/paste menu).

If we double click on the textview also the menu option appear.

I would like to know how to hide the menu in double click ?

NB:I need the text is always selectable.

Upvotes: 3

Views: 1226

Answers (2)

mob_web_dev
mob_web_dev

Reputation: 2362

When text is selectable android will show the text selection menu in double tap.To disable this problem we need to implement GestureDetector with onTouch. Then in the GestureListener set setTextIsSelectable(true) in onLongPress and setTextIsSelectable(false) in double tap.

Upvotes: 2

Ugurcan Yildirim
Ugurcan Yildirim

Reputation: 6142

Here is what you have to do:

setTextIsSelectable

When you call this method to set the value of textIsSelectable, it sets the flags focusable, focusableInTouchMode, clickable, and longClickable to the same value. These flags correspond to the attributes android:focusable, android:focusableInTouchMode, android:clickable, and android:longClickable. To restore any of these flags to a state you had set previously, call one or more of the following methods: setFocusable(), setFocusableInTouchMode(), setClickable() or setLongClickable().

Source: https://developer.android.com/reference/android/widget/TextView.html#setTextIsSelectable(boolean)

Upvotes: -1

Related Questions