user18148338
user18148338

Reputation:

Kotlin code convert to Java code Hide Bottom navigation bar?

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

Answers (1)

markspace
markspace

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

Related Questions