使Android Textview或EditText可选

使Android Textview或EditText可选,android,android-edittext,textview,selectable,Android,Android Edittext,Textview,Selectable,我想在我的android项目中选择EditText或Textview。 该项目适用于android 4.0+。我添加了以下内容:txtView.setxtisselectable(true)以及:txtView.setCustomSelectionActionModeCallback(new myCallback()) 使我的自定义选择菜单。 但是当我想要选择文本时,这个错误发生了 W/TextView﹕ TextView does not support text selection. Act

我想在我的android项目中选择
EditText
Textview
。 该项目适用于android 4.0+。我添加了以下内容:
txtView.setxtisselectable(true)
以及:
txtView.setCustomSelectionActionModeCallback(new myCallback())
使我的自定义选择菜单。
但是当我想要选择文本时,这个错误发生了

W/TextView﹕ TextView does not support text selection. Action mode cancelled.
我搜索了错误,但没有找到解决方案。我该怎么办?


<TextView
    android:id="@+id/id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textIsSelectable="true"
    android:text="" />

*API级别11及更高版本

setTextIsSelectable确实解决了Android 7.1.1上的问题。设置为Enabled(false)和true不起作用

editText.setTextIsSelectable(true);
我的确切情况是设置setFocusable(false)并添加一个onClickListener,然后设置setFocusable(true)和onClickListener(null)在操作中给了我错误


(语法不正确,但你明白了)

检查你是否有android:focusable=“false”或android:focusableInTouchMode=“false”在您的XmlWidget中,看一看:您真正想做什么..选择edittext和textview文本,或者在选择此小部件时显示颜色。@Surenderkumar我想让用户能够共享他们在textview中选择的文本。@RafiduzzamanSonnet谢谢,我会试试。你在我的
EditText
上的wellcome@HamedPuting
textIsSelectable
会打断EditText焦点,特别是当你关闭键盘时(你再也无法打开它)。你可以提供@dextor任何解决方案,以便我可以编辑我的答案,似乎这只与
EditText
有关。所以不需要改变你的答案。它真的有效吗?我也试过了。但是,它不起作用。尝试选择带有文本视图的文本时获取以下警告日志:文本视图不支持文本选择。操作模式已取消。