Android data-binding (similar to WPF)?

后端 未结 8 2061
情话喂你
情话喂你 2020-12-13 12:56

I have searched for some similar questions before posting - however I have a general question when it comes to Android and data binding (and the other answers I check did no

8条回答
  •  不思量自难忘°
    2020-12-13 14:01

    There is nothing "baked" into the Android SDK which provides equivalent databinding functionality found in MS WPF. Google is providing a lower level interface for the various devices running Android. To date, higher level application frameworks have not emerged from the Android development community. (IMHO, it would take a monster company like Google to create such a thing, given all the different constraints on a framework for all the various Android devices.)

    You could create a set of databinding classes in your own application to handle your needs for the MVVM pattern. The "Databinders" would set the relevant event handlers on Android View objects and run some appropriate method on your ViewModel objects in response. They would also translate change events (that you define) on the ViewModel into the appropriate property assignments on the View objects.

    Whether that turns out to be worthwhile for your application is a judgment call. My guess is that it would require more effort to write the Databinder classes than just to hook the lower level View event handlers directly. Frameworks are useful primarily when you didn't have to write them yourself.

提交回复
热议问题