【发布时间】:2017-12-06 19:09:28
【问题描述】:
我有一个TextView 绑定了 Enabled、Clickable 和 Click。加载 activity 时,已启用和 Clickable 绑定为 false 值,但 TextView 无法禁用且仍可单击。将绑定值更改为 true & 然后为 false 后,TextView 被禁用。
我发现问题与绑定 Click 事件有关。绑定 Click 后,就会出现上述问题。在不绑定 Click 事件的情况下,它可以按预期工作。
在下面的示例代码中,前 2 个TextViews 是可以的。最后一个有绑定Click的不行。
顺便说一句,我在TextInputEditText 上遇到了这个问题。我发现这种情况也适用于TextView,因此我使用TextView 进行说明。
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="test textview can be disabled at load"
style="@style/EntryTextStyle"
local:MvxBind=" Enabled RouteMarker.ArrivalNotice" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="test textview with no click command, can be disabled at load"
style="@style/EntryTextStyle"
local:MvxBind=" Enabled RouteMarker.ArrivalNotice;
Clickable RouteMarker.ArrivalNotice" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="test textview with click command cannot be disabled at load"
style="@style/EntryTextStyle"
local:MvxBind=" Enabled RouteMarker.ArrivalNotice;
Clickable RouteMarker.ArrivalNotice;
Click DoSomethingCommand" />
private IMvxAsyncCommand _doSomethingCommand;
public IMvxAsyncCommand DoSomethingCommand
{
get
{
_doSomethingCommand = _doSomethingCommand ?? new MvxAsyncCommand(async () =>
{
await Task.Delay(10);
});
return _doSomethingCommand;
}
}
知道如何解决吗?
谢谢
【问题讨论】: