12

I'm using a EditText in a PopupWindow. It shows OK, but the selection markers do not show up in the EditText. Neither does the Options menu change when I long press in the EditText. In LogCat I see a warning

TextView does not support text selection. Action mode cancelled.

As a result, the EditText cannot copy/paste text from the clipboard. Is there any way to get the "normal" EditText behaviour in a PopupWindow?

This code shows the problem, but I have also tried lots of variations:

EditText edit = new EditText(getContext());
edit.setBackgroundColor(Color.BLUE);
PopupWindow popup = new PopupWindow(edit, 100, 100, true);
popup.setBackgroundDrawable(new BitmapDrawable());
popup.showAtLocation(this, Gravity.NO_GRAVITY, 100, 200);
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Gerrit Beuze
  • 903
  • 2
  • 10
  • 26

1 Answers1

-1

Try this,

   editText.setSelectAllOnFocus(true);
Aneez
  • 205
  • 3
  • 12
  • No, that is not relevant to the problem I was having. I can select the text OK, but the markers do not appear. Alos, this question is 2 1/2 years old: I worked around the problem with a completely different approach. – Gerrit Beuze Mar 26 '14 at 07:43
  • Sorry , while searching I came to see this question. Any way , You got any solution now ? – Aneez Mar 26 '14 at 07:46
  • No, not for this specific problem. I ended up using a DialogFragment rather than a popup window containing an EditView. Not what I wanted, but I coudl not find a way to make the popup window work. – Gerrit Beuze Mar 27 '14 at 08:42