gpt4 book ai didi

java - 编辑文本的粘贴选项

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:41:27 26 4
gpt4 key购买 nike

我有一个编辑文本,我想在其中粘贴一些文本。我可以从某个网页复制文本,但无法将文本粘贴到我的 edittext 控件中。如何让我的 edittext 粘贴一些文本。这是我的 main.xml for edittext ;

enter code here

<EditText
android:id="@+id/enter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight= "2"
android:scrollbars="vertical"
android:textColor="@color/black"
/>

谢谢

最佳答案

这是在 Android 4.4.2 Samsung S4 上;

TextView 的文档说:

To allow users to copy some or all of the TextView's value and paste it somewhere else, set the XML attribute android:textIsSelectable to "true" or call setTextIsSelectable(true). The textIsSelectable flag allows users to make selection gestures in the TextView, which in turn triggers the system's built-in copy/paste controls.

还有另一个名为 android:cursorVisible 的 Textview 属性它确定是否应调用有关复制/粘贴回调的系统。

默认情况下,我相信这两个都是正确的,并且选择/复制/粘贴机制已经启用。我无法通过使用 android:textIsSelectable="false" 来改变这种行为,但是如果我设置 android:cursorVisible="false" 最初你不能在 EditText 中粘贴任何东西.只有在您输入内容后,光标和选择行为才会再次启用。也许这应该在代码内部处理而不是在布局 xml 中处理,或者它可能与 android:inputType 有关,这对我来说也没有什么不同。

因此,如果默认情况下未启用粘贴,请尝试在 EditText 的布局 xml 中设置 android:cursorVisible="true"

关于java - 编辑文本的粘贴选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10593724/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com