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
With the development of the Internet, traditional...
Recently, various opinions have emerged on the de...
Author: Tang Qin, Deputy Secretary-General and Re...
Live streaming has gradually evolved from an earl...
On December 9, 2021, "space teachers" Z...
Today's Internet industry is becoming more an...
Competition is only a means, making money is the ...
The past week has seen a series of major events i...
From the earliest example of Perfect Diary to Hua...
recently In Nalangtun, Bamu Township, Tian'e ...
When it comes to "iron and blood supplements...
I have been in the Internet circle for 6 years an...
For those who work in operations , the word they ...
This year's home appliance industry can be de...