Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding button path image (Using MvxBaseAndroidTargetBinding) Android
    text
    copied!<p>How to binding path image to button, using MvxBaseAndroidTargetBinding?</p> <p>1) I Create a binding</p> <pre><code>public class MvxButtonIconBinding: MvxBaseAndroidTargetBinding { private readonly View _view; public MvxButtonIconBinding(View view) { _view = view; } public override void SetValue(object value) { string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); path = Path.Combine(path, "pictures"); path = Path.Combine(path, (string)value); if (File.Exists(path)) { var dr = Drawable.CreateFromPath(path); Button b = _view as Button; var drawables = b.GetCompoundDrawables(); foreach (var d in drawables) if (d!=null) d.Dispose(); // To avoid "out of memory" messages b.SetCompoundDrawablesWithIntrinsicBounds(null, dr, null, null); } else { Console.WriteLine("File {0} does not exists", path); } } public override MvxBindingMode DefaultMode { get { return MvxBindingMode.OneWay; } } public override Type TargetType { get { return typeof(string); } } protected override void Dispose(bool isDisposing) { if (isDisposing) { } base.Dispose(isDisposing); } </code></pre> <p>}</p> <p>2) Setup the binding :</p> <pre><code>registry.RegisterFactory(new MvxCustomBindingFactory&lt;View&gt;("ButtonIcon", view =&gt; new MvxButtonIconBinding(view))); </code></pre> <p>3) Create button_list.аxml</p> <pre><code>&lt;Button android:id="@+id/ButtonArticle" android:layout_width="fill_parent" android:layout_height="160dp" android:gravity="bottom|center" android:paddingBottom="5dp" android:paddingTop="5dp" local:MvxBind="{'Click':{'Path':'Command1'},'ButtonIcon':{'Path':'Item.PictureFileName'}}" android:textSize="14dip" android:textColor="@drawable/ToggleButtonSelector" /&gt; </code></pre> <hr> <p><strong>Which path transmit properties PictureFileName? Show me an example please.</strong></p> <hr> <p><a href="https://stackoverflow.com/questions/12914544/ssue-with-binding-to-gridlayout-to-android"><em>Taken from</em></a></p>
 

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