【问题标题】:Text select able but not editable in the textView文本可以在 textView 中选择但不可编辑
【发布时间】:2023-04-02 08:15:02
【问题描述】:

我希望 textView 中的文本 可选择、可复制但不能粘贴或可写。 我想防止用户在现有文本上书写或粘贴。我怎样才能做到这一点?

我在 xml 中使用了以下代码,但它没有达到目的。

     <TextView
            android:id="@+id/text_body_story"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="text_body_story"
            android:inputType="textMultiLine"
            android:scrollHorizontally="false"
            android:textSize="14sp"
            android:textColorHighlight="#ffee04"
            android:textIsSelectable="true"
            android:longClickable="true"
            android:padding="10dp"
            android:layout_marginBottom="10dp"
            />

【问题讨论】:

  • 什么不起作用?
  • 如果我启用文本可选择,那么它是可复制和可编辑的(用户可以写任何他想要的;尽管当活动关闭时它会消失)。但我希望用户只能选择和复制文本,但不能编辑或写入。

标签: android textview jquery-ui-selectable


【解决方案1】:

从您的TextView 中删除android:inputType 属性。拥有输入类型是允许用户修改文本的原因。

【讨论】:

    【解决方案2】:

    试试这个

    android:inputType="none"
    

    【讨论】:

      猜你喜欢
      • 2023-03-05
      • 2011-11-05
      • 2010-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-17
      相关资源
      最近更新 更多