如何启用PopupWindow选择标记的EditText? [英] How to enable selection markers for EditText in PopupWindow?

查看:1308
本文介绍了如何启用PopupWindow选择标记的EditText?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 PopupWindow 使用的EditText 。它显示OK,但选择标记不要在的EditText 显示。无论是否在选项菜单的变化,当我长preSS在的EditText 。在LogCat中我看到一条警告

  

TextView中不支持文本选择。操作模式取消了。

这样一来,从剪贴板中的EditText 不能复制/粘贴文本。 有没有什么办法让正常的EditText 的行为 PopupWindow

这code说明什么问题,但我也尝试过很多变化:

 的EditText编辑=新的EditText(的getContext());
edit.setBackgroundColor(Color.BLUE);
PopupWindow弹出=新PopupWindow(编辑,100,100,真正的);
popup.setBackgroundDrawable(新BitmapDrawable());
popup.showAtLocation(此,Gravity.NO_GRAVITY,100,200);
 

解决方案

试试这个,

  editText.setSelectAllOnFocus(真正的);
 

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);

解决方案

Try this,

   editText.setSelectAllOnFocus(true);

这篇关于如何启用PopupWindow选择标记的EditText?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆