Android Text Selection Listener

白昼怎懂夜的黑 提交于 2019-11-30 07:15:27

The key term you're looking for here, to help you with your research, is ActionMode, provided that your target is honeycomb or newer.

The API docs (scroll down to "using the contextual action mode) do an ok job of explaining things, once you find what you're looking for, which is the biggest barrier to their use, but basically what you're going to need to do is this:

  1. set your EditText to be selectable (android:textIsSelectable="true" or setTextIsSelectable(true);
  2. Implement the ActionMode.Callback interface and provide your own menu items.

NOTE: as mentioned above, this only works for API level 11+. If you're targeting earlier platforms, getting the events for text selection is much more complicated.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!