2
votes

I have a Switch and a TextInputEditText. Both 'Enabled' are bound to the same field in the viewmodel.

When the activity is loaded, the bound field is set to false. The Switch is disabled as expected. However, the TextInputEditText is enabled. The 'Clickable' has the same issue. Text is bound successfully.

After changed the bound field to true and then false, the TextInputEditText Enable & Clickable work correctly. It seems that it only happens when it is loaded initially.

            <android.support.v7.widget.SwitchCompat
                style="@style/EntryTextStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                local:MvxLang="Text LabelDeferArrivalNotice"
                local:MvxBind="Checked RouteMarker.DeferArrivalNotice; Enabled RouteMarker.ArrivalNotice" />
            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <android.support.design.widget.TextInputEditText
                    android:id="@+id/edittext_route_marker_EffectiveFromDateTime"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:editable="false"
                    android:focusableInTouchMode="false"
                    style="@style/EntryTextStyle"
                    local:MvxLang="Hint LabelEffectiveFromTime"
                    local:MvxBind="Text DateTimeToString(RouteMarker.EffectiveFromDateTime); 
                                   Enabled RouteMarker.ArrivalNotice;
                                   Clickable RouteMarker.ArrivalNotice;
                                   Click PromptDeferTimeCommand" />

Is there anything special I have to do with the TextInputEditText?

Thanks

1
You shouldn't have to do anything special with TextInputEditText. Is it possible RouteMarker.ArrivalNotice is being set from a thread other than the main thread? - Trevor Balcom
I found that the issue is related to binding Click, not particularly to EditText. I have created a new post for it: stackoverflow.com/questions/47668130/… - Nick

1 Answers

0
votes

This is an issue with MvvmCross, as Stuart said, there are some interaction between ICommand.CanExecute and the Enabled property. Switching the binding to :

local:MvxBind="Click PromptDeferTimeCommand;Enabled RouteMarker.ArrivalNotice;Clickable RouteMarker.ArrivalNotice;"

Hope to help somebody who searched this problem.