0

我必须隐藏在 jetpack compose 中长按文本字段文本后出现的 TextField 的复制、粘贴、剪切、调用选项。我可以使用下面的 kotlin 代码来做到这一点。我必须使用 Jetpack compose 的 TextField 来实现这一点

LayoutBinding?.EtJioNumber?.setCustomSelectionActionModeCallback(object:ActionMode.Callback {

      override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {
        Console.debug(javaClass.simpleName,"onCreateActionMode")

        if (menu != null) {
          menu?.removeItem(android.R.id.shareText)
          menu?.removeItem(android.R.id.copy)
          menu?.removeItem(android.R.id.paste)
          menu?.removeItem(android.R.id.cut)
          menu?.removeItem(android.R.id.selectAll)
          menu.removeItem(android.R.id.autofill);
        }


        return false
      }

      override fun onPrepareActionMode(mode: ActionMode?, menu: Menu?): Boolean {
        Console.debug(javaClass.simpleName,"onPrepareActionMode")
      
       return false
      }

      override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean {
        Console.debug(javaClass.simpleName,"onActionItemClicked")
        return false
      }

      override fun onDestroyActionMode(mode: ActionMode?) {
        Console.debug(javaClass.simpleName,"onDestroyActionMode")
      }

    })
4

0 回答 0