I'd like to dynamically add options to my screen menu on Android, I've seen several examples, but all turned to a single button.
Assuming I have it.
override fun onCreateOptionsMenu(menu: Menu, menuInflater: MenuInflater) {
menu.clear()
val menu1 = menu
.add(Menu.NONE, 1, Menu.NONE, null)
.setIcon(R.drawable.ic_add_round_white)
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
val menu2 = menu
.add(Menu.NONE, 2, Menu.NONE, null)
.setIcon(R.drawable.ic_edit_white)
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
}
In this example I can generate 2 buttons to the top bar of my screen, the question is how to increment options inside these buttons?
I use kotlin, but java would solve it.