EditText控件不能使用textIsSelectable进行可编辑吗?

funnyone 2015-12-11 08:32:43
我使用textIsSelectable属性对于EditText控件,发现不能输入,可输入与可选择矛盾吗?

<EditText
android:text="Hello World!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40sp"
android:textIsSelectable="true"
/>


...全文
204 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
funnyone 2015-12-13
  • 打赏
  • 举报
回复
确实如上面所说。 见textview的构造函数:

 } else if (isTextSelectable()) {
            // Prevent text changes from keyboard.
            if (mEditor != null) {
                mEditor.mKeyListener = null;
                mEditor.mInputType = EditorInfo.TYPE_NULL;
            }
            bufferType = BufferType.SPANNABLE;
            // So that selection can be changed using arrow keys and touch is handled.
            setMovementMethod(ArrowKeyMovementMethod.getInstance());
        } else if (editable) {
            createEditorIfNeeded();
            mEditor.mKeyListener = TextKeyListener.getInstance();
            mEditor.mInputType = EditorInfo.TYPE_CLASS_TEXT;
        } else {
jklwan 2015-12-12
  • 打赏
  • 举报
回复
这个属性是TextView的,是用来设置长按选中的。看TextView的代码isTextSelectable是在可编辑的前面的,所以你设置这个属性后他的可编辑就变成false了。

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧