作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在 PopupWindow
中使用 EditText
。它显示 OK,但选择标记未显示在 EditText
中。当我在 EditText
中长按时,选项菜单也没有改变。在 LogCat 中我看到一个警告
TextView does not support text selection. Action mode cancelled.
因此,EditText
无法从剪贴板复制/粘贴文本。有没有办法在 PopupWindow
中获得“正常”EditText
行为?
此代码显示了问题,但我也尝试了很多变体:
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);
最佳答案
试试这个,
editText.setSelectAllOnFocus(true);
关于android - 如何在 PopupWindow 中为 EditText 启用选择标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8035159/
我是一名优秀的程序员,十分优秀!