dataBinding的import导入

1>main_sub.xml




    
        
        
        
    

    

        

        

        

2>main.xml导入main_sub.xml




    
        
        
    

    
        
    

3>MainActivity

public class MainActivity extends AppCompatActivity {
    ActivityMainBinding activityMainBinding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activityMainBinding= DataBindingUtil.setContentView(this,R.layout.activity_main);
        UserInfo userInfo=new UserInfo("于振锋",5);
        activityMainBinding.setUserInfo(userInfo);
        activityMainBinding.setButtClick(new ButtonClickListener(this));
    }
}



作者:北京小强户外
链接:https://www.jianshu.com/p/5aae2167078b
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

你可能感兴趣的:(jetpack,android,android,studio,ide)