I am able to get "activity-wide" data binding to work without any difficulties whatsoever. However, when I try to setup bindings for specific Views, say inflated Views that I'm programmatically adding to a LinearLayout, nothing I've tried works.
For example, binding data to an Activity's view is trivial. Typically in the onCreate() method one just has to add:
MainActivityBinding binding = DataBindingUtil.setContentView(this, R.layout.main_activity);
User user = new User("Test", "User");
binding.setUser(user);
That's it! The view main_activity.xml will be "bound" to the binding through some magic (this is my problem) and variable substitution will work as expected in the main_activity.xml.
I consulted Google's documentation regarding RecyclerView use and attempted to utilize this method in my inflated Views. I did this by creating a ListItemBinding (my .xml is just called list_item.xml and this file is auto-generated off of the .xml layout) for each ViewHolder, the ListItemBinding is passed in to the ViewHolder to be held as a reference through the Constructor of each ViewHolder.
Now of course this does not work, and I am guessing that the reason for this is that there's no explicit tie between my View and the Binding, however, there's no tie between the Activity above and the Binding either, so why does that work?
I'm digging into the source code to see how the binding works on Activities, I'm sure that will have my answer, but if anyone else can chime in before I spend multiple hours, I would appreciate the head-start!
I will report all findings here, thank you very much