选择一个TextView +复制文本? [英] Select + copy text in a TextView?
问题描述
有没有一种方法,让用户选择一个TextView /复制文本?我需要的EditText的相同的功能,你可以长preSS控制,并得到全选/复印在弹出的选项,但我需要控制看起来像一个TextView。
Is there a way to allow the user to select / copy text in a TextView? I need the same functionality of EditText where you can long-press the control and get the popup options of select all / copy, but I need the control to look like a TextView.
试过喜欢做一个EditText使用编辑=无选项或inputType =none的几件事情,但那些仍然保留一个EditText,我不想要的,
Tried a few things like making an EditText use the editable="none" option or inputType="none", but those still retain the framed background of an EditText, which I don't want,
感谢
-------更新----------------------
------- Update ----------------------
这是99%,在那里,所有我想要的是选择高亮可见(橙色的东西)。除此之外,它的好,可以住,这虽然:
This is 99% there, all I'd want is for the selection hilight to be visible (the orange stuff). Other than that it's good, could live with this though:
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:editable="false"
style="?android:attr/textViewStyle"
android:textColor="@color/white"
android:textAppearance="@android:style/TextAppearance.Medium"
android:cursorVisible="false"
android:background="@null" />
我想这是因为受到了cursorVisible =假,但没有造成光标即使没有所做的任何选择present。
I guess it's being caused because of cursorVisible="false" but without that the cursor is present even without any selection being made.
推荐答案
机器人:textIsSelectable 作品(至少在ICS - 我还没有检查在早期版本)
android:textIsSelectable works (at least in ICS - I haven't yet checked in earlier versions)
<TextView
android:id="@+id/deviceIdTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true"
android:text="" />
这篇关于选择一个TextView +复制文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!