Configure ActionMenu EditText

I want to provide simple formatting buttons for EditText, for example, a button that inserts <strong></strong>if no text was selected, and otherwise wraps around the selected text in the tags <strong>.

I am using v7 support library with ActionBarCompat. I was able to run custom ActionModewhen changing my focus EditText. However, when I touch the text in this for a long time EditText, another menu opens ActionModewith the copy / paste / ... buttons, which are supposedly the default behavior of Android. How can I suppress this second menu, but still allow the user to select parts of the content EditText?

Alternatively, I would like to be able to customize the default menu using setCustomSelectionActionModeCallback(...), but using the support library. How can i do this?

+4
source share
1 answer

Unfortunately, TextViewthey EditTextdo not provide an API for using classes ActionBarCompat. But you must be able to redefine this behavior.

onLongClickListener, supportInvalidateOptionsMenu(). "true" OnLongClickListener.onLongClick(), , . onPrepareOptionsMenu , . TextView "selectAll", "cut", "copy" "paste", .

+3

Source: https://habr.com/ru/post/1523607/


All Articles