在启用链接器的情况下,将MvvmCross从4.2.3更新到4.4.0后,Android EditText绑定被破坏 [英] Android EditText Binding is broken after MvvmCross update from 4.2.3 to 4.4.0 with Linker enabled

查看:81
本文介绍了在启用链接器的情况下,将MvvmCross从4.2.3更新到4.4.0后,Android EditText绑定被破坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于MvvmCross从4.2.3升级到4.4.0,我之前运行的MvvmCross Android应用已损坏

My MvvmCross Android app which was working before now is broken because of MvvmCross update from 4.2.3 to 4.4.0

<EditText
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   local:MvxBind="Text Login" />

public string Login
{
    get { return _login; }
    set { SetProperty(ref _login, value); }
}

链接器,如果有的话,请包括在内:

LinkerPleaseInclude if of course there:

public void Include(EditText text)
        {
            text.Enabled = !text.Enabled;
            text.TextChanged += (sender, args) => text.Text = "" + text.Text;
            text.Hint = "" + text.Hint;
            text.Click += (s, e) => text.Visibility = text.Visibility - 1;
        }

        public void Include(TextView text)
        {
            text.TextChanged += (sender, args) => text.Text = "" + text.Text;
            text.Hint = "" + text.Hint;
            text.Click += (s, e) => text.Text = text.Text + "";
        }

链接器仅SDK"已启用. 对于禁用的链接器,它可以正常工作. 其他绑定也可以正常工作(单击按钮,可见性等).

Linker "SDK Only" enabled. For disabled linker it works fine. Other bindings works fine as well (button clicks, visibilities, etc).

如何告诉链接器正确处理此问题? 哪里可能出问题了?

How to tell linker to handle this properly? What could be wrong here?

推荐答案

EditTextTextView的绑定目标使用AfterTextChanged事件,该事件可能被链接了.将其添加到您的Include方法中,而不是TextChanged,它应该可以工作:

The binding target for EditText and TextView uses the AfterTextChanged event, which probably gets linked away. Add that to your Include methods instead of TextChanged and it should work:

public void Include(TextView text)
{
    text.AfterTextChanged += (sender, args) => text.Text = "" + text.Text;
    text.Hint = "" + text.Hint;
    text.Click += (s, e) => text.Text = text.Text + "";
}

我认为您不需要为EditText使用单独的方法,因为EditText是从TextView继承的.

I don't think you need a separate method for EditText as EditText inherits from TextView.

这篇关于在启用链接器的情况下,将MvvmCross从4.2.3更新到4.4.0后,Android EditText绑定被破坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆