Skip to content

Instantly share code, notes, and snippets.

@yogacp
Last active August 13, 2019 19:22
Show Gist options
  • Save yogacp/828a3f079bb8b9f4478543674cb4b8b2 to your computer and use it in GitHub Desktop.
Save yogacp/828a3f079bb8b9f4478543674cb4b8b2 to your computer and use it in GitHub Desktop.
/**
* Extension for view visibility
*/
fun View.visible() {
visibility = View.VISIBLE
}
fun View.gone() {
visibility = View.GONE
}
/**
* How to use the code above
*/
class MyActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val progressBar = finViewById<ProgressBar>(R.id.progress_bar)
// Call the view extension
progressBar.visible()
progressBar.gone()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment