Reputation:
How to Implement code to java
I'm confused about this line of code _, destination, _ ->
I want this code to be possible in java
navController.addOnDestinationChangedListener { _, destination, _ ->
if(destination.id == R.id.full_screen_destination) {
toolbar.visibility = View.GONE
bottomNavigationView.visibility = View.GONE
} else {
toolbar.visibility = View.VISIBLE
bottomNavigationView.visibility = View.VISIBLE
}
}
Upvotes: 0
Views: 53
Reputation: 11030
According to this page, the underbar is used for unused variables in a lambda expression. So one way to translate this would be to just assign some variable name, then don't use it.
So perhaps something like this (code is untested).
navController.addOnDestinationChangedListener ( (x, destination, y) -> {
if(destination.id == R.id.full_screen_destination) {
toolbar.visibility = View.GONE;
bottomNavigationView.visibility = View.GONE;
} else {
toolbar.visibility = View.VISIBLE;
bottomNavigationView.visibility = View.VISIBLE;
}
}
)
Upvotes: 1