Android – customize the actionmenu of EditText

I want to provide simple formatting buttons for EditText. For example, insert the button < strong > < / strong >. If no text is selected and the selected text is wrapped in < strong >, otherwise

I am using the support library V7 and actionbarcompat. I try to start the custom actionmode when the focus of EditText changes. However, when I touch the text in EditText for a long time, another actionmode menu will open, including the copy / paste /... Button, which may be the default behavior of Android. How to disable the display of the second menu, But still let the user select part of the EditText content?

Or, I want to be able to use setcustomselectionactionmodecallback (...) to customize the default menu, but use the support library. How can I do this?

resolvent:

Unfortunately, textview and EditText do not provide APIs for using actionbarcompat class. However, you should be able to override this behavior

Set a custom onlongclicklistener, where you can set your own status information in the activity and call supportinvalideoptionsmenu(). Be sure to return "true" from the onlongclicklistener. Onlongclick() method, indicating that you have used click. Then, in onprepareoptionsmenu, You can add any new menu items you need to customize the action bar. I recommend not using textview context menu items ID 'SelectAll', 'cut', 'copy' and 'paste', just for safety

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>