I\'m trying to create custom selection menu but it does not work on a device with rom MIUI and Android 6. The result is common menu with copy
and select all>
I had similar problem, maybe my solution would help someone. I had to make a view composed of several horizontal neighboring EditText
's, and add ability to paste text to them (one letter of text to one editText)
I used ActionMode.Callback
's approach and it was working fine, except Xiaomi devices. The solution for Xiaomi devices was using OnLongClickListener
on edit texts and create PopupMenu
on long click:
editText.setOnLongClickListener(v -> {
PopupMenu menu = new PopupMenu(context,v);
MenuInflater inflater = menu.getMenuInflater();
inflater.inflate(R.menu.paste_menu_item, menu.getMenu());
menu.setOnMenuItemClickListener(item -> {
pasteText();//some custom function to handle selected action
return false;
});
menu.show();
return true;
});