Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes - you can use fluent bindings in Android if you want to.</p> <p>Exactly the same code should work.</p> <p>You'll need to get references to the ui controls using <code>FindViewById&lt;Type&gt;()</code>, then you can bind them.</p> <p>For example, in TipCalc you can add identified controls like:</p> <pre><code> &lt;EditText android:id="@+id/FluentEdit" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="number" android:textSize="24dp" android:gravity="right" /&gt; </code></pre> <p>and then implement binding using:</p> <pre><code> protected override void OnViewModelSet() { SetContentView(Resource.Layout.View_Tip); var edit = this.FindViewById&lt;EditText&gt;(Resource.Id.FluentEdit); var set = this.CreateBindingSet&lt;TipView, TipViewModel&gt;(); set.Bind(edit).To(vm =&gt; vm.SubTotal); set.Apply(); // for non-default properties use 'For': // set.Bind(edit).For(ed =&gt; ed.Text).To(vm =&gt; vm.SubTotal); // you can also use: // .WithConversion("converter", "optional parameter") // .OneTime(), .OneWay() or .TwoWay() } </code></pre> <p>Additionally, you can convert any FooActivity into a data-binding MvxFooActivity by:</p> <ul> <li>inheriting from FooActivity to provide events from lifetime events in an EventSourceFooActivity </li> <li>inheriting from EventSourceFooActivity to provide a datacontext in an MvxFooActivity</li> <li>you can then write your code inside activities inheriting from MvxFooActivity</li> </ul> <p>To see, the code required, see:</p> <ul> <li><a href="https://github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross.Droid.Fragging/MvxEventSourceFragmentActivity.cs" rel="nofollow noreferrer">https://github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross.Droid.Fragging/MvxEventSourceFragmentActivity.cs</a></li> <li><a href="https://github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross.Droid.Fragging/MvxFragmentActivity.cs" rel="nofollow noreferrer">https://github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross.Droid.Fragging/MvxFragmentActivity.cs</a></li> </ul> <p>You'll see the same code in all the mvx adapted Activities - MvxActivity, MvxTabActivity, ... There is a little cut-and-paste here, but as much code as possible is place in shared extension methods.</p> <p>In previous versions, people have used this technique to bind monogame and google ads activities - eg see <a href="https://stackoverflow.com/questions/13201174/insert-a-monogame-view-inside-mvvmcross-monodroid-activity/13201800#13201800">Insert a Monogame view inside MvvmCross monodroid Activity</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload