将xamarin.android从8.3版本升级到9.0后,绑定将停止工作。经过调查,我发现与MvxBind的资源ID不同并且由于该问题而发生的问题。
升级后
// aapt资源值:0x7F010830
public const int MvxBinding_MvxBind = 2130774064;
// aapt resource value: 0x1
public const int MvxBinding_MvxLang = 1;
之前
// aapt resource value: 0
public const int MvxBinding_MvxBind = 0;
// aapt resource value: 0x1
public const int MvxBinding_MvxLang = 1;
出现的问题是MvxAndroidViewBinder.cs。方法ApplyBindingsFromAttribute不被调用:
public virtual void BindView(View view, Context context, IAttributeSet attrs)
{
using (
var typedArray = context.ObtainStyledAttributes(attrs,
MvxAndroidBindingResource.Instance.BindingStylableGroupId))
{
int numStyles = typedArray.IndexCount;
for (var i = 0; i < numStyles; ++i)
{
var attributeId = typedArray.GetIndex(i);
if (attributeId == MvxAndroidBindingResource.Instance.BindingBindId)
{
ApplyBindingsFromAttribute(view, typedArray, attributeId);
}
else if (attributeId == MvxAndroidBindingResource.Instance.BindingLangId)
{
ApplyLanguageBindingsFromAttribute(view, typedArray, attributeId);
}
}
typedArray.Recycle();
}
有什么主意吗?