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
1. What did Lukou Community do from 0 to 1? Lukou...
The lottery originated from gambling and is a gam...
"Nezha" has grossed over 3.5 billion yu...
The most frustrating thing about humid weather is...
Everyone is familiar with electrocardiogram and e...
"Sunny to cloudy East wind level 1 to 2 This...
With the ability to quickly and accurately proces...
There have long been theories about who is more l...
Another Spring Festival is here. During this joyo...
Why does Apple only allow upgrades but not downgr...
Tutorial Introduction Master the basic Python syn...
What will the world be like in 500 years? Wheneve...
For newbies doing live broadcasts, they don’t nee...
Plane mirrors can help us adjust our attire and a...
“The bigger the wind and waves, the more fish the...