I have setup data binding with some custom attributes in my Application. The generated classes look correct and I can even see where the default values are bounded to the attributes in the generated binding classes in the executeBindings
method. I need to access these custom attributes in the initial OnResume
of an Activity when it's first created and found that the bindings execute AFTER that lifecycle method is called. So when I check initially, the attribute is null. Obviously on subsequent OnResume
calls after an OnPause
everything works fine. Is there a way to force the initial binding to happen prior to my initial check in OnResume
?
Yes, you can call executePendingBindings()
on the binding.
Evaluates the pending bindings, updating any Views that have expressions bound to modified variables. This must be run on the UI thread.