I have an EditText et
. When I want to modify its text, the android soft keyboard pops up.
The problem is that in some devices, the cut, copy and print button are all on top bar and due to the fact that the keyboard pops up while I am modifying the text in EditBox, I cant copy and paste in those devices. (Its a ListView and it is not scrollable)
The option that easily solves my problem is to close the soft keyboard once my text in et
is selected.
I have searched a lot but I couldn't find any listener for this. Is there any solution to this issue?
I understand that I can write my own ActionMode
but I don't want to rewrite the android's default copy/paste bar.
I also tried to use setOnLongClickListener()
on et
but for some reasons it's not trigered when I select the text.
et.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(et.getWindowToken(), 0);
Toast.makeText(ProfileActivity.this, "text is selected", Toast.LENGTH_LONG).show();
return true;
}
});