Can I select the text of a TextView from a function call to display an ActionMenu

23 Views Asked by At

I have confirmed that I can select TextView in Android from a function call to Text. However, the ActionMenu (including textSelectHandle) does not appear at this time. In other apps, I am able to achieve this without a long tap by the user. I'm sure there is a way to do this, but if you know of one, I would love to hear about it.

What I tried below.

  • I can select text, but the action menu display, such as copy, does not appear.
TextView.setSelectAllOnFocus(true)
TextView.requestFocus()
// or
TextView.performLongClick()
Selection.selectAll(TextView.text as Spannable)
  • Actions menu such as copy can be displayed, but textSelectionHandle and others do not appear.
val actionModeCallback = object : ActionMode.Callback {
// ...
}
activity?.startActionMode(actionModeCallback, ActionMode.TYPE_FLOATING)
  • I also tried using EditText, but the behavior is the same as TextView.
0

There are 0 best solutions below