Issue
I am new in Kotlin. I have a view that I need to show or hide in conditional ways.
How can I do this in Kotlin?
In Java:
public void showHide(View view){
if (view.getVisibility() == View.VISIBLE) {
view.setVisibility(View.INVISIBLE);
} else {
view.setVisibility(View.VISIBLE);
}
}
Solution
In response to this answer, I believe a Kotlin-styled way to accomplish this can also be written as:
fun showHide(view:View) {
view.visibility = if (view.visibility == View.VISIBLE){
View.INVISIBLE
} else{
View.VISIBLE
}
}
Answered By - Faysal Ahmed
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.