简体   繁体   中英

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.

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

</>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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