I'm using the android toolbar at my MvvmCross 3.5.1 app but once I updated it to MvvmCross 4.0 databindings are broken. As long as there is no base appcompat activity I have to implement my own:
MvxActionBarEventSourceActivity : AppCompatActivity , IMvxEventSourceActivity
{
...
}
And then base bindable mvx activity:
MvxActionBarActivity : MvxActionBarEventSourceActivity, IMvxAndroidView
{
...
}
App starts just fine and I can see my toolbar but bindings are just "silent" and don't work. Same implementation works find for MvvmCross 3.5.
You can find full sample here: https://dl.dropboxusercontent.com/u/19503836/MvvmCross4_Toolbar_Bindings.zip
Please advise.
You need to override OnCreateView
and AttachBaseContext
and use the MvxAppCompatActivityHelper
to support bindings: https://github.com/MvvmCross/MvvmCross-AndroidSupport/blob/master/MvvmCross.Droid.Support.V7.AppCompat/MvxAppCompatActivity.cs#L78
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
too: https://github.com/MvvmCross/MvvmCross-AndroidSupport/tree/master/Samples
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With