ibrahimsn98 / SmoothBottomBar

A lightweight Android material bottom navigation bar library
MIT License
1.98k stars 255 forks source link

Added setSelectedItem method #83

Closed milon27 closed 3 years ago

milon27 commented 3 years ago

//overload setupWithNavController
fun setupWithNavController(menu:Menu,navController: NavController) {
        NavigationComponentHelper.setupWithNavController(menu, this, navController)
    }

+fun setupWithNavController(navController: NavController) {
+   NavigationComponentHelper.setupWithNavController(this.menu, this, navController)
+    Navigation.setViewNavController(this,navController)
+}

//select an item 
+fun selectItem(pos:Int){
+     try{
+         this.itemActiveIndex=pos
+          NavigationUI.onNavDestinationSelected(this.menu.getItem(pos), this.findNavController())
+      }catch (e:Exception){
+          throw Exception("set menu using PopupMenu")
+      }
+  }