1. Basic structure 1.1 JavaBeans Objects
1.2 Layout File
1.3 Activity
The above three steps complete the basic data binding 2. Dynamic Updates When the data of the JavaBean object changes, the View is automatically updated. Normal data sources can only be bound. If you want to update dynamically, you must use Observable to store data. The following are three ways to implement Observable. 2.1 Observable Object Implement android.databinding.Observable or inherit its implementation class
2.2 Observable Fields Basic data types have corresponding Observable classes public final ObservableField<String> firstName = new ObservableField<>(); 2.3 Observable Collections ObservableArrayMap<String, Object> mapUser = new ObservableArrayMap<>(); user.put("firstName", "Google"); 2.4 References Whether it is an object, field or collection, data is stored in the form of Observable. The next step is to reference it in the layout.
3. RecyclerView dynamic binding
|
<<: Interview experience: WeChat, NetEase Games, Jinshan Xishanju, Renren
>>: Looking for Easter eggs in the code, Google is no longer the Google you know
On December 18, in response to media reports that...
"How can I get others to pay attention to my...
Friends who have used this kind of water dispense...
As the proportion of short videos in the content ...
The main focus of this course is to explain how t...
When it comes to parasitic infections, many peopl...
On March 18, a news report that "a Zhejiang ...
Early yesterday morning, Apple pushed the iOS 18....
Not long ago, Pinduoduo's market value surpas...
Two weeks ago, spy photos of SF Express's thre...
Hello, I'm Jiang Xiaoxi Poyang Lake's ric...
There is still a month to go until Christmas, and...
The New Year is coming soon There must be a lot o...
WeChat Mini Program is an application that users ...