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
In the slave society and the early feudal society...
In today's global warming, glaciers have beco...
Whether it is adolescent boys and girls or adults...
With the advent of the 5G era, virtual reality (V...
Is the Yellow River going to be renamed? This riv...
01 Changes in the communication model: from manua...
I believe most advertisers are very familiar with...
Pesticide residues have always been a concern for...
Mini programs provide convenience for publicity a...
"Man is iron, rice is steel, and if you don&...
As the 2022 Android flagships debut one after ano...
"Ah, it's midnight again so soon? But I ...
The world is changing, Google needs to change, an...
The use of Fragment is a commonplace~~~ 1. Overvi...
As the saying goes, "Without rice, there is ...