Android `@BindingAdapter` setter not being called -
here bindingadapter:
public class bindings{     @bindingadapter({"font"})     public static void setfont(textview textview, string fontname) {         textview.settypeface(fontcache.getinstance(textview.getcontext()).get(fontname));     } }   *instead of using "font" annotation parameter, i've tried "bind:font", "android:font", , "app:font", , made corresponding changes in layout, bindingadapter still not called
here layout use bindingadapter (bind_layout.xml):
<?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:app="http://schemas.android.com/apk/res-auto">      <data></data>      <linearlayout         android:layout_width="match_parent"         android:layout_height="match_parent"         android:orientation="horizontal">          <button             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:background="@null"             font="@{`fontawesome-webfront`}"             android:text="@string/double_left"/>     </linearlayout> </layout>   *this layout included in activity's layout set using databindingutils.setcontentview
here activity layout includes bind_layout.xml:
public class acreatesemester extends appcompatactivity {     private list<createitemview> mcreateitemviews;     private linearlayout mitemcontainer;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         databindingutil.setcontentview(this,r.layout.a_create_items);         mitemcontainer = (linearlayout) findviewbyid(r.id.item_container);         mitemcontainer.addview(new createitemview(this, item.getdefaultitem()));     }  }   the 3 files referenced here listed in entirety.
the way know bindingadapter not being called because set breakpoint on method , in body, , breakpoint never reached. 
any idea why bindingadapter not firing?
i think missed connect view viewmodel in activity.
public class acreatesemester extends appcompatactivity { private list<createitemview> mcreateitemviews; private linearlayout mitemcontainer;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     acreateitemsbinding binding =  databindingutil.setcontentview(this,r.layout.a_create_items);     mitemcontainer = (linearlayout) findviewbyid(r.id.item_container);     mitemcontainer.addview(new  createitemview(this,item.getdefaultitem()));     binding.setview(yourviewhere); }      
Comments
Post a Comment