DataBindings break after upgrade to MvvmCross 4.0 when using AppCompatActivity

I use the Android toolbar in my MvvmCross 3.5.1 application, but after I updated it to MvvmCross 4.0, the data binding is broken. While there is no underlying appcompat activity, I have to implement my own:

MvxActionBarEventSourceActivity : AppCompatActivity , IMvxEventSourceActivity { ... } 

And then the basic mvx binding activity:

 MvxActionBarActivity : MvxActionBarEventSourceActivity, IMvxAndroidView { ... } 

The application starts just fine, and I see my toolbar, but the bindings are just silent and not working. The same is true for MvvmCross 3.5.

Here you can find the full sample: https://dl.dropboxusercontent.com/u/19503836/MvvmCross4_Toolbar_Bindings.zip

Please inform.

+5
source share
1 answer

You need to override OnCreateView and AttachBaseContext and use the MvxAppCompatActivityHelper to support the bindings: https://github.com/MvvmCross/MvvmCross-AndroidSupport/blob/master/MvvmCross.Droid.Support.V7.AppCompat/MvAAppCompat/MvAivityCpatc/AvActivity

  public override View OnCreateView(View parent, string name, Context context, IAttributeSet attrs) { var view = MvxAppCompatActivityHelper.OnCreateView(parent, name, context, attrs); return view ?? base.OnCreateView(parent, name, context, attrs); } protected override void AttachBaseContext(Context @base) { base.AttachBaseContext(MvxContextWrapper.Wrap(@base, this)); } 

There is a sample available to implement Toolbar instead of Actionbar : https://github.com/MvvmCross/MvvmCross-AndroidSupport/tree/master/Samples

+5
source

Source: https://habr.com/ru/post/1243990/


All Articles