Last active
August 13, 2019 19:22
-
-
Save yogacp/828a3f079bb8b9f4478543674cb4b8b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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