Edittext that make selection on long click but do not show context menu?

后端 未结 2 1077
广开言路
广开言路 2021-01-17 02:37

i want to provide custom handlers that cut,copy text.

Target on Longclick

  1. Context Menu Should not appear.
  2. Text could get selected with tracker
2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-17 03:00

    you want to get rid of the ActionMode? and create your own??

    you can override this and get notified when the default is about to be displayed

      @Override
      public void onSupportActionModeStarted(ActionMode mode) {     
        super.onSupportActionModeStarted(mode);
        //you can add your custom ui here
        mode.setCustomView(....);// it takes a view
    }
    

    if you want to close it then you call mode.finish(); you can call it there to close if or finish it if you do not need it.

    when it is about to die it calls this onSupportActionModeFinished(ActionMode mode)` the methods i have stated are for the support libraries, hope you know that.

    The rest is cheese

提交回复
热议问题