m4gn1f1c4nt
m4gn1f1c4nt

Reputation: 198

Xamarin Edittext = true then not clickabel

Im tring to change my Edittext field to a textview field or something else when the answer is right. To Sum up what im trying to achive: When UserInput is right the input field cant be changed anymore.

Thanks for your Help!

PS:Sry for my spelling

Upvotes: 0

Views: 119

Answers (1)

SushiHangover
SushiHangover

Reputation: 74144

You can toggle the Enabled property so the EditText can not be edited:

aEditTextInstance.Enabled = false;

This will disable the widget so it will change its appearance.

Or you could add both a TextView and EditView to the layout, and set the EditView to a Visibility of Gone, once the user get the correct answer, copy the answer to the TextView and swap Visibility of both widgets:

Layout example:

<EditText 
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:enabled="true"
    android:inputType="text"
    android:visibility="visible"
    />
<TextView 
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:enabled="false"
    android:visibility="gone"
    />

Code example:

textView.Text = editText.Text;
textView.Visibility = ViewStates.Visible;
editText.Visibility = ViewStates.Gone;

Upvotes: 1

Related Questions