1

我有一个包含 5 个 EditTexts 的布局,我需要是只读的。

对于其中三个,像这样设置可编辑属性:

    android:editable="false"

...成功了(使 EditTexts 只读)。

但是,有了两个,它就没有效果了。我在检查 XML 时发现,只读和非只读的区别在于,那些无视“editable=false”指令的有一个明确的输入类型属性,即:

     android:inputType="numberDecimal"

...和:

     android:inputType="number"

IOW,这有效(小部件是只读的):

<EditText
    android:id="@+id/edttxtDesc"
    android:layout_width="0dip"
    android:layout_height="wrap_content"
    android:editable="false"
    android:background="@drawable/greyframe"
    android:layout_weight="5" />

...这不是(小部件仍然可编辑):

<EditText
    android:id="@+id/edttxtCount"
    android:layout_width="0dip"
    android:layout_height="wrap_content"
    android:inputType="number"
    android:editable="false"
    android:background="@drawable/greyframe"
    android:layout_weight="2" />

因此,似乎具体了解 EditText 中允许的数据类型并将所述小部件设为只读是彼此厌恶的。有没有解决方法,还是我只需要忍受这个限制?

4

0 回答 0