Android equivalent of KVO?



I was reading chapter 12 and saw that a code example updated a model class instance and button text that displayed some of the information held in the model. I was wondering if Android has an equivalent of KVO, thinking that the way I would do something similar in iOS would be to bind data changing in the model to text in the button?



There is no direct equivalent in Android to KVO. A few things you can investigate are:

Java Beans’ “Property Change” API, a la: … pport.html

Java’s Observer/Observable API: … vable.html

In either case, you’re going to be doing the work of manually notifying listeners and ensuring things like thread safety. The Property Change API is most similar to KVO, but you don’t get the magic quite like you do with Cocoa.