Is it possible to add some item in the context men

2019-04-07 15:52发布

When I enter some text and press and hold on it then context menu is presented with items like cut,copy,select text and so on.

Is there any way to add my own custom item to this context menu ? I do not how this things works but I guess that should be possible to register something in the manifest just like registering activities and broadcasts . . .

Thanks,

Any ideas are wellcomed

enter image description here

2条回答
对你真心纯属浪费
2楼-- · 2019-04-07 16:15

Have you tried putting an onLongClickListener on your EditText? This won't let you add to the current list, but you can make your own dialog show up and then add all the options above, or some of them, or none of them and your own.

I'm not sure if exactly what you're asking for is possible, and if it is my way is a little bit more work, but you'll have full control.

查看更多
老娘就宠你
3楼-- · 2019-04-07 16:18

Is there any way to add my own custom item to this context menu ?

Only for widgets in your own activities, not for the system as a whole.

Also, EditText is problematic even for your own activities, as some device manufacturers are bypassing the normal context menu system, so you can't add to them.

That being said, for your own activities, just follow the instructions to create a context menu for the widgets of interest.

查看更多
登录 后发表回答