更新時(shí)間:2016年11月30日15時(shí)45分 來(lái)源:傳智播客Android培訓(xùn)學(xué)院 瀏覽次數(shù):
1
|
< variable name = "user" type = "cn.itcast.mvvmdemo.User" /> |
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
|
public class User { private String firstname; private String lastname; public User(String firstname, Stringlastname) { this .firstname = firstname; this .lastname = lastname; } public String getFirstname() { return firstname; } public void setFirstname(Stringfirstname) { this .firstname = firstname; } public String getLastname() { return lastname; } public void setLastname(Stringlastname) { this .lastname = lastname; } } |
1
2
3
|
< TextView android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "@{user.firstname}" /> |
01
02
03
04
05
06
07
08
09
10
|
public class MainActivity extends AppCompatActivity { private User user; @Override protected void onCreate(BundlesavedInstanceState) { super .onCreate(savedInstanceState); ActivityMainBinding binding =DataBindingUtil.setContentView( this , R.layout.activity_main); user = new User( "尼古拉斯凱奇" , "趙四" ); binding.setUser(user); } } |
C/C++培訓(xùn)之GTK+學(xué)習(xí)之旅—GTK+簡(jiǎn)介
2016-11-28Android培訓(xùn)之開(kāi)發(fā)架構(gòu)規(guī)范(4)
2016-11-28Android培訓(xùn)之開(kāi)發(fā)架構(gòu)規(guī)范(3)
2016-11-28Android培訓(xùn)之開(kāi)發(fā)架構(gòu)規(guī)范(2)
2016-11-28Android培訓(xùn)之開(kāi)發(fā)架構(gòu)規(guī)范(1)
2016-11-28Android培訓(xùn)之dip、dp、px、sp和屏幕密度
2016-11-22北京校區(qū)