其他分享
首页 > 其他分享> > ViewBinding简单使用

ViewBinding简单使用

作者:互联网

官方文档:https://developer.android.google.cn/topic/libraries/view-binding?hl=zh-cn#java

    viewBinding {
        enabled = true
    }

如下图:

public class MainActivity extends AppCompatActivity {
    private ActivityMainBinding mBinding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(mBinding.getRoot());
        mBinding.tvHello.setText("ViewBindingDemo");
    }
}

源码分析

标签:mBinding,调用,cn,setContentView,ViewBinding,简单,使用,ActivityMainBinding,onCreate
来源: https://blog.csdn.net/zhangjin1120/article/details/122178217