Quick Tip — How to set the visibility of a button
Hello ! I’m Xavier Jouvenot and in this small post, I am going to explain how to set the visibility of a button.
Self promotion: You can find other articles on Android development on my website 😉
To specify the visibility of a
Button, there are several solutions and the first one we are going to specify a default visibility for a
To do so, we are going to modify the
Button XML definition, and add one attribute to it. This attribute is
android:visibility and tell if you want the button to be visible are not. By default, this attribute is set to visible.
Here is how such
Button XML definition looks like:
<!--Some other attributes -->
Specifying the attribute in the XML is great! But if you want to modify the visibility of a
EditText while the program is running, then, you must use some Java code and the method
setVisibility. Here is how it looks like:
Button button = findViewById(R.id.buttonId);
Thank you all for reading this article, And until my next article, have a splendid day 😉
Originally published at http://10xlearner.com on May 29, 2020.