为的EditText粘贴选项选项、EditText

2023-09-06 16:26:50 作者:何必、委屈求全

我有一个EditText,我想一些文字贴在里面。我可以将文本从某些网页中复制,但我不能在我的EditText control.How粘贴文本,我可以让我的EditText粘贴一些text.Here是我的EditText main.xml中;

I have an edittext and I would like to paste some text in it. I can copy the text from some web page but I am not able to paste the text in my edittext control.How can I enable my edittext to paste some text.Here is my 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三星S4;

This is on Android 4.4.2 Samsung S4;

有关的TextView 文档说:

要允许用户复制的部分或全部的TextView的价值和粘贴的  在别处,将XML属性的的android:textIsSelectable ,以  真或致电 setTextIsSelectable(真)。该textIsSelectable标志  使用户可以在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.

也有另一种叫做TextView的attribure 安卓cursorVisible 的决定,如果系统应该调用有关复制/粘贴回调。

There is also another Textview attribure called android:cursorVisible which determines if the system should be invoked about the copy/paste callbacks.

在默认情况下,我相信这两个是真实和选择/复制/粘贴机制已经启用。 textIsSelectable =FALSE,但如果我设置的android:cursorVisible =FALSE最初你不能粘贴的EditText里的任何东西。你输入的东西只有经过,游标和选择行为变得再次启用。也许这应该在code内,而不是在布局XML的处理,或者它可能与的android:inputType下也没有有所作为我。

By default I believe both of these are true and selection/copy/paste mechanics are already enabled. I could not change that behaviour by using android:textIsSelectable="false" but if I set android:cursorVisible="false" initially you can't paste anything inside the EditText. Only after you type something in, cursor and selection behaviour becomes enabled again. Maybe this should be handled inside the code rather than in the layout xmls, or it might be related to android:inputType which also did not make a difference for me.

因此​​,尝试设置的android:cursorVisible =真正的在你的EditText的布局XML如果糊默认不启用

So try setting android:cursorVisible="true" in your EditText's layout xml if paste is not enabled by default.