Can Android widgets be readonly when given an InputType?

250 Views Asked by At

I have a Layout with 5 EditTexts that I need to be readonly.

For three of them, setting the editable property like so:

    android:editable="false"

...does the trick (makes the EditTexts readonly).

With two, though, it has no effect. I see on examining the XML that the difference between those that are and are not readonly is that those which disregard the "editable=false" directive have an explicit input type property, namely:

     android:inputType="numberDecimal"

...and:

     android:inputType="number"

IOW, this works (widget is readonly):

<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" />

...and this doesn't (widget is still editable):

<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" />

So it seems that getting specific about the type of data allowed in an EditText and making said widget readonly are anathema to each other. Is there a workaround, or do I just have to live with this limitation?

0

There are 0 best solutions below