在build.gradle
中加入
android{
viewBinding {
enabled = true
}
}
在对应Activity
如下定义(e.g. MainActivity
)
private ActivityMainBinding binding;
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
调用View
//调用TextView,其名为TXT
binding.TXT.setText("String");
标签:调用,setContentView,Binding,binding,使用,ActivityMainBinding,TXT
From: https://www.cnblogs.com/MarkDespite/p/16660782.html