Description for Toolbar in Android:

In Android toolbar is similar to an actor bar. Toolbar is a view group that can be placed at any where in layout. We can eaisly replace an action bar with toolbar.toolbar provides more features than action bar . A toolbar may contain a combination of elements from start to end.
Steps to use toolbar given below
Add new activity 
In design add toolbar
Pallete->containers->toolbar
Set constraints for toolbar.
Add textview and Give name it to like toolbar or any other set constraints for textview.
In styles.xml set theme of tool bar dark action bar
In activity main xml- add Android I’d :name =main activity”
In main activity write code given below
Set support action bar(toolbar)
}
Override fun on createoption menu(menu:menu?):boolean{
menu inflated.inflatr(R.menu.activity_third_menu,menu)
return true
}
Override fun on optionsitemselected(item:menu item):boolean{
Val msg =when(item.(itemid)
{

R.id menu(item_add->”add is clicked”
R.id menu(item_update->”update is clicked”
R.id .menu(item_delete->”delete is clicked”
R.id text 1->”text one is clicked”
R.id text2->”text two is clicked”
else->”settings is clicked”
}
Toast.maketext{(context this.msg,toast.LENGTH_LONG.show()
return true


Youtube video link:

https://youtu.be/M5XeD0bFdbQ

Leave a Reply

Your email address will not be published. Required fields are marked *