Home > Mobile >  A problem of two-way data binding transform data type
A problem of two-way data binding transform data type

Time:11-17

 public class MainActivity extends AppCompatActivity {

@ Override
Protected void onCreate (Bundle savedInstanceState) {
Super. OnCreate (savedInstanceState);
ActivityMainBinding binding=DataBindingUtil. The setContentView (this, R.l ayout. Activity_main);
The Config Config=new Config ();
Binding. SetCfg (config);
}

}


 public class Config extends BaseObservable {
Public ObservableInt stopTimeBegin=new ObservableInt ();

Public Config () {
}

@ InverseMethod (" stringToi ")
Public static String itoString (ObservableInt I) {
Return a String. The valueOf (i.g et ());
}

Public static ObservableInt stringToi (String STR) {
Return new ObservableInt (Integer. The valueOf (STR));
}
}


 




Name="CFG"
Type="com. Wind. Databinding. Config"/& gt;

Android: layout_width="match_parent"
Android: layout_height="match_parent" & gt;

The android: id="@ + id/text"
Android: layout_width="match_parent"
Android: text='@={CFG. ItoString (CFG) stopTimeBegin)}'
Android: layout_height="match_parent" & gt;






How not to do what type conversion, there is no problem..

CodePudding user response:

Have been a reason
 CFG. ItoString 

It should be
 Config. ItoString 
  • Related