简体   繁体   English

如何减少viewBinding的使用,从布局中调用(text,edit)views

[英]How to reduce the use of viewBinding, to call (text,edit)views From layout

I want to decrease the use of binding in my code我想减少代码中绑定的使用

fun setVisibility() {
                    binding.tvFact.visibility = View.VISIBLE
                    binding.tvTimeStamp.visibility = View.VISIBLE
                    binding.progressBar.visibility = View.GONE
                }

If you do not like the syntax try this:如果您不喜欢该语法,请尝试以下操作:

binding.apply{
  tvFact.visibility = View.VISIBLE
  tvTimeStamp.visibility = View.VISIBLE
  progressBar.visibility = View.GONE
}

You can set these values in XML itself as default ones, so it won't process each time to set it.您可以in XML itself中将这些值设置为默认值,因此不会每次都进行设置。

<View
...
   android:visibility="gone">

</>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM