In android how to set navigation drawer header image and name programmatically in class file?

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
View hView = navigationView.getHeaderView(0);
TextView nav_user = (TextView) hView.findViewById(R.id.nav_name);
nav_user.setText(user);

Leave a Comment