android popup menu kotlin
snippet in kotlin

android popup menu kotlin

user2563

  val popupMenu: PopupMenu = PopupMenu(this,button)  
           popupMenu.menuInflater.inflate(R.menu.popup_menu,popupMenu.menu)  
           popupMenu.setOnMenuItemClickListener(PopupMenu.OnMenuItemClickListener { item ->  
                    when(item.itemId) {  
                    R.id.action_crick ->  
                        Toast.makeText(this@MainActivity, "You Clicked : " + item.title, Toast.LENGTH_SHORT).show()  
                    R.id.action_ftbal ->  
                        Toast.makeText(this@MainActivity, "You Clicked : " + item.title, Toast.LENGTH_SHORT).show()  
                    R.id.action_hockey ->  
                        Toast.makeText(this@MainActivity, "You Clicked : " + item.title, Toast.LENGTH_SHORT).show()  
                }  
                true  
           })  
           popupMenu.show()