[英]How do I make android:textIsSelectable=“true” work with my intent?
I'm having trouble making my textview
editable - while I can make it editable, I can't pass the text to another activity via an intent
. 我在使textview
可编辑时遇到了麻烦-虽然我可以使其可编辑,但是我无法通过intent
将文本传递给另一个活动。
In the xml
of my View
activity, for my textViewComment
textbox, I have: 在我的View
活动的xml
中,对于我的textViewComment
文本框,我有:
<TextView
android:id="@+id/textViewComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/textboxes_for_contact"
android:textIsSelectable="true"
The text in the textbox
is indeed selectable, I am able to copy it with a long press. 文本textbox
确实是可选的,我可以长按复制它。
However, I have an Edit
activity - when an edit button is clicked in View
activity, the text in textViewComment
should be passed to this Edit
activity with an intent
. 但是,我有一个Edit
活动-在View
活动中单击一个编辑按钮时, textViewComment
的文本应通过intent
传递给此Edit
活动。 Instead, the Edittext
in my EditView
is empty. 而是,我的Edittext
中的EditView
为空。
When I remove android:textIsSelectable="true"
the text is passed via the intent successfully. 当我删除android:textIsSelectable="true"
,文本将通过意图成功传递。 But... I can't edit it in the textview
. 但是...我无法在textview
对其进行编辑。
I also tried it programmatically with commentname.setTextIsSelectable(true);
我也用commentname.setTextIsSelectable(true);
以编程方式尝试了它commentname.setTextIsSelectable(true);
but this gives the same problem. 但这带来了同样的问题。
In ViewContact
class I have 在ViewContact
类中
i.putExtra("comment", commentname.getText());
In EditContact
class: 在EditContact
类中:
comment = i.getStringExtra("comment");
The xml
in my EditContact
class for textViewComment
is: 该xml
在我EditContact
类textViewComment
是:
<EditText
android:id="@+id/textViewComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textCapSentences"
android:background="@drawable/textboxes_for_contact"
android:maxLength="360"
/>
Any idea how I can make the text in ViewContact
selectable while also passing the intent
successfully? 有什么想法可以使ViewContact
的文本ViewContact
可选择状态,同时还可以成功传递intent
吗? Is this a known issue? 这是一个已知的问题?
Replace: 更换:
i.putExtra("comment", commentname.getText());
with: 有:
i.putExtra("comment", commentname.getText().toString());
and see if you have better luck. 看看你是否有更好的运气。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.