Home > Software engineering >  How to reduce the use of viewBinding, to call (text,edit)views From layout
How to reduce the use of viewBinding, to call (text,edit)views From layout

Time:07-09

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
                }

CodePudding user response:

If you do not like the syntax try this:

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

CodePudding user response:

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">

</>
  • Related