Issue
I am trying out the Android's BottomNavigationView implementation as per Material Design
However, on the MainActivity code I am getting a warning that OnNavigationItemSelectedListener
is deprecated - see the below snapshot
Have tried get an alternative method to work with the BottomNavigationView but I cannot find it.
Looking for help from anyone with a way out but in the meantime I have matched my BottomView's menu items ids with the fragment destination ids and I successfully achieved Navigation but with a limitation of not being able to update my toolbar title with the Fragment's name.
Solution
Just use the OnItemSelectedListener
interface:
kotlin
bottomNavigationView?.setOnItemSelectedListener {
// do stuff
return@setOnItemSelectedListener true
}
Java
bottomNavigationView.setOnItemSelectedListener(item -> {
// do stuff
return true;
});
Answered By - Ali Moghadam
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.