更新時(shí)間:2017-04-14 來(lái)源:黑馬程序員Android培訓(xùn)學(xué)院 瀏覽量:
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); } } |
Android培訓(xùn)之初探安卓MVVM框架設(shè)計(jì)(中)
2017-04-14Android培訓(xùn)之初探mvvm框架設(shè)計(jì)(上)
2017-04-14Android培訓(xùn)之內(nèi)存泄露的各種原因詳解
2017-04-14Android培訓(xùn)之a(chǎn)db常見(jiàn)問(wèn)題整理
2017-04-14Android培訓(xùn)之開(kāi)發(fā)架構(gòu)規(guī)范(4)
2017-04-14Android培訓(xùn)之開(kāi)發(fā)架構(gòu)規(guī)范(3)
2017-04-14