i want to get view by id myProfile reference from menu item Navigation View..
its my code from menu_navigation.xml
<item
android:id="@+id/myProfile"
android:icon="@drawable/nav_person"
android:tint="@color/btngrey"
android:checkable="false"
android:title="My Profile" />
This code works for me.
Declare a variable Menu menu = toolbar.getMenu();
for a menu from a Toolbar
or Menu menu = navigationView.getMenu();
from a NavigationView
in your onCreate()
method.
Get itemMenu
using menu.findItem(R.id.item)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.